Can I show different content or route to a different Backend Service based on the client's operating system (Operating System)?
Short answer
Yes, on the HTTP vService. The Operating System condition detects the client's operating system from the User-Agent header; one or more operating systems are selected from the list, and the condition is met if one of the selected ones matches. The match is exact: selecting Windows does not cover Windows Phone, and selecting iOS does not cover KaiOS. If the condition is bound to a Conditional Backend Services block, the request goes to different Backend Services; if it is bound to the Location Redirection action, the client is redirected to another address (e.g. a platform-specific download page); if it is bound to the Show Content action, a content page defined in TR7 is shown. To separate clients whose operating system is recognized from those whose operating system is not recognized, the ready-made If the client operating system is recognized condition is used.
Background
Browsers and applications introduce themselves and the platform they run on in the User-Agent header in every request (e.g. Mozilla/5.0 (Windows NT 10.0; Win64; x64) …). The operating system is derived from the signatures in this text. The value of the header is the client's declaration; it can be changed by the client.
Problem: Platforms Expect Different Content or Applications
It may be wanted that a download page offers each platform its own installation package, that an application version prepared only for specific operating systems runs on separate servers, or that an information page is shown to unsupported platforms. Instead of parsing User-Agent on the Backend Service side, the distinction is made in TR7 with a condition that looks at the operating system of the request.
Solution: Three Methods
The three methods use the same Operating System condition; the difference is where the matching request goes.
| Your situation | Suitable method |
|---|---|
| Requests coming from specific operating systems must go to separate servers; the address must not change | Method 1: Conditional Backend Services |
| Users on specific operating systems must be sent to another address (e.g. a store or download page) | Method 2: Location Redirection |
| TR7's own page must be shown without going to the Backend Service (e.g. an unsupported platform warning) | Method 3: Show Content |
Method 1: Conditional Backend Services Recommended
- How it works The Operating System condition is bound to a Conditional Backend Services (Content Switching) block; requests coming from the selected operating systems go to the Backend Services of the block, and the others go to Default Backend Services.
- Where it is openedLoad Balancer → Conditions → Operating System · vService form → + Conditional backend services
- Requirement The target servers being defined as Backend Services
- vService type HTTP
Step-by-Step Configuration
If the target servers are not yet defined as Backend Services in TR7, they are defined with Load Balancer → Backend Services → Add; if they are defined, this step is skipped (How is a Backend Service added; which information is required?).
The condition form is opened with Load Balancer → Conditions → Add (how to add).
Condition Name is entered (e.g. os-windows) and Criteria = Operating System is selected. The Operating System field opens empty; at least one operating system is selected from the searchable list. Multiple selections work with or logic. Values with similar names are separate: if both Windows and Windows Phone are targeted, both are selected.
The Add button is clicked.
The Load Balancer → Load Balancer vService List steps are followed and the HTTP vService is opened with Edit.
The + Conditional backend services button in the Default Backend Services table is clicked.
The condition from step 3 is selected in the Select Conditions field of the block, and the Backend Services to which these clients will go are selected in the Backend Service selector.
The Save button is clicked.
Verification
On the Logs & Tracking → HTTP Logs screen of the vService, an operating system is selected in the Operating System filter and the Backend Service value of the records is checked. For the record to be created, the LOG field must be on in the vService.
Requests coming from the selected operating system → the Backend Service of the blockA request is sent with a Windows User-Agent.
curl -s -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" http://203.0.113.10/The response comes from the Backend Service of the blockMethod 2: Location Redirection
- How it works The request that fits the condition is redirected with 3xx to the address in the Redirect Location field; the client sends a new request to the new address. This is not a server selection.
- Where it is openedLoad Balancer → Actions · vService form → Details → Actions
- Requirement The Operating System condition created in steps 2–4 of Method 1; if Location Redirection is saved without a condition, it never runs
- vService type HTTP
Step-by-Step Configuration
The Load Balancer → Actions → Add steps are followed.
Action Type = Location Redirection is selected; the target address is entered in the Redirect Location field (e.g. https://www.example.com/indir/windows), the redirect code (e.g. 302) is selected in the Redirect Code field, and the Operating System condition is selected in the Conditions field.
The Add button is clicked.
The Load Balancer → Load Balancer vService List steps are followed, the vService is opened and the Details button at the top of the form is clicked.
The created action is selected in the Actions field.
The Save button is clicked.
Verification
A request is sent with a Windows User-Agent and the response headers are checked.
curl -sI -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" http://203.0.113.10/HTTP/1.1 302 · Location: https://www.example.com/indir/windowsMethod 3: Show Content
- How it works For the request that fits the condition, the page in the Content Pages profile is shown with the selected status code, without going to the Backend Service.
- Where it is openedLoad Balancer → Actions · vService form → Details → Actions
- Requirement The page to be shown being defined as a Content Pages profile; the Operating System condition created in steps 2–4 of Method 1
- vService type HTTP
Step-by-Step Configuration
The Load Balancer → Actions → Add steps are followed.
Action Type = Show Content is selected; the page to be shown is selected in the Content Page field (if there is none, a new page is created with Add in the drop-down list), the status code (default 200) is selected in the Status Code field, and the Operating System condition is selected in the Conditions field.
The Add button is clicked.
The Load Balancer → Load Balancer vService List steps are followed, the vService is opened and the Details button at the top of the form is clicked.
The created action is selected in the Actions field.
The Save button is clicked.
Verification
A request is sent with the User-Agent of the targeted operating system.
curl -si -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" http://203.0.113.10/The selected status code and the page in the Content Pages profileCommon Mistakes
- Using operating system detection for a security decision.
User-Agentis the client's declaration and can be changed; an access restriction is not based on this condition alone. - Thinking that similar names cover each other. The match is exact: selecting Windows does not cover Windows Phone traffic, and selecting iOS does not cover KaiOS traffic.
- Forgetting unrecognized clients. A request that sends no
User-Agentor comes with an unknown signature matches no operating system and goes to Default Backend Services. To separate these clients, the ready-made If the client operating system is NOT recognized condition is selected. - Making the mobile distinction with the operating system. If only a "is it mobile" distinction is needed, the ready-made If the client is mobile condition or the Mobile Platform condition is more suitable (Can I send mobile devices to a separate backend?).
- Looking for the condition on the L7 TCP vService. The Operating System condition is used only on the HTTP vService.
- Creating a redirect loop. If the target address is published from the same vService, the negated form of the target path is added to the condition of Location Redirection with and; otherwise, the redirected request is redirected again.
How it is done in the documentation
