Can I send mobile devices to a separate backend?
Short answer
Yes, on the HTTP vService. The shortest way is to select the ready-made If the client is mobile condition that comes with the product in the Conditional Backend Services block; there is no need to define a separate condition. If a platform distinction is needed, a Mobile Platform condition is defined; for a distinction by operating system, an Operating System condition; and for a custom pattern, an HTTP Header condition that checks the User-Agent header. The Location Redirection action is used to send the user to the mobile site. All mobile detections rely on the User-Agent header.
Problem: Mobile Users Should Go to a Different Application
If a separately optimized application or API version is run for mobile devices, mobile requests need to go to these servers, and desktop requests to the existing servers.
Solution: Three Methods
Method 1 and Method 2 send the request to different Backend Services; Method 3 does not select a server, it redirects the client to another address.
| Your situation | Suitable method |
|---|---|
| Separating all mobile devices is enough | Method 1: Ready-made condition: If the client is mobile |
| I want to use specific platforms (e.g. only Android), operating systems or my own User-Agent pattern | Method 2: Mobile platform / Operating system / HTTP header condition |
I want to send the user to the mobile site (e.g. m.example.com) | Method 3: Location redirection |
Method 1: Ready-Made Condition: If the client is mobile Recommended
- How it works This condition, which comes with the product, compares the
User-Agentheader with known mobile signatures; its NOT form If the client is NOT mobile is also in the selection list. - Where it is opened vService form → + Conditional backend services → Select Conditions
- Requirement The target servers being defined as Backend Services
- vService type HTTP
Step-by-Step Configuration
If the mobile servers are not yet defined as Backend Services in TR7, they are added first; if they are defined, this step is skipped. With Load Balancer → Backend Services → Add, Backend Service Name and Address are entered for each server and a Health Check profile is selected. Details: How is a Backend Service added; which information is required?
The Load Balancer → Load Balancer vService List steps are followed and the HTTP vService is opened.
The + Conditional backend services button in the Default Backend Services table is clicked (Conditional Backend Services).
If the client is mobile is selected in the Select Conditions field of the block; the mobile Backend Services are selected in the Backend Service selector. Ready-made conditions do not appear in the Conditions list and are not edited.
The Save button is clicked.
Verification
On the Left Monitor Panel → Load Balancer vServices → vService → Logs & Tracking → HTTP Logs screen, the Device Type value of the request is compared with the Backend Service that responded to the request (Viewing HTTP Logs). For the record to be created, the LOG field must be on in the vService.
Mobile request → mobile Backend Service · desktop request → Default Backend ServicesA request is sent with a mobile User-Agent.
curl -s -A "Mozilla/5.0 (Linux; Android 13; Pixel 7) Mobile" http://203.0.113.10/The response comes from the mobile Backend ServiceMethod 2: Mobile Platform / Operating System / HTTP Header Condition
- How it works The platform or the operating system detected from the
User-Agentheader, or a custom pattern, is defined with a condition and bound to the conditional block. - Where it is openedLoad Balancer → Conditions · vService form → + Conditional backend services
- Requirement The target servers being defined as Backend Services
- vService type HTTP
Step-by-Step Configuration
The Load Balancer → Conditions → Add steps are followed; the form is described in the Conditions · How to Add? section.
Condition Name is entered and Criteria is selected as needed:
| Criteria | Field filled in | Example |
|---|---|---|
| Mobile Platform | One or more platforms from the Mobile Platform list; the condition is met if one of the selected ones matches | Android |
| Operating System | Operating systems from the Operating System list | iOS |
| HTTP Header | Header Name = Request · User-Agent, matching Includes, Case insensitive checked, Query | Mobile |
The Add button is clicked.
Steps 2–5 of Method 1 are applied; in step 4, this condition is selected instead of the ready-made condition.
Verification
As in Method 1, on the HTTP Logs screen, the Operating System or Device Type value of the request is compared with the Backend Service that responded to the request.
Request from the selected platform → Backend Service of the blockMethod 3: Location Redirection
- How it works A request that fits the condition is redirected to the mobile site (e.g.
https://m.example.com) with a 3xx; this is not a server selection, the client sends a new request to the new address. Details: How do I redirect a specific URL to another URL with a 301/302? - Where it is openedLoad Balancer → Actions · vService form → Details → Actions
- Requirement A condition (if Location redirection is saved without a condition, it never runs); the ready-made If the client is mobile condition can also be selected
- vService type HTTP
Step-by-Step Configuration
The Load Balancer → Actions → Add steps are followed.
Action Type = Location redirection is selected; the address of the mobile site is entered in the Redirect Location field, the redirect code (e.g. 302) is selected in the Redirect Code field, and If the client is mobile or the condition created in Method 2 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 mobile User-Agent and the response headers are checked.
curl -sI -A "Mozilla/5.0 (Linux; Android 13; Pixel 7) Mobile" http://203.0.113.10/HTTP/1.1 302 · Location: https://m.example.comCommon Mistakes
- Using mobile detection for a security decision.
User-Agentcan be changed by the client; it is not used for an access restriction. - Forgetting mobile browsers that request the desktop view. When the browser sends a desktop
User-Agent, the request is not considered mobile and goes to Default Backend Services. - Creating a loop when redirecting to the mobile site. If the mobile site is published from the same vService, the Host of the mobile site is added to the condition of the Location redirection in its NOT form; otherwise, the redirected request is redirected again.
- Looking for the Mobile platform condition on an L7 TCP vService. Mobile conditions can be selected only on an HTTP vService.
How it is done in the documentation
