We use something like this:
server {
listen 80;
server_name ~^(?<custom>.+)\.website\.com$;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_intercept_errors on;
if ($http_user_agent ~* iphone|android ) {
proxy_pass
http://frontends/userland/mobile/$custom;
break;
}
proxy_pass
http://frontends/userland/front/$custom;
}
}
/userland/mobile/$custom and /userland/front/$custom are Tornado handlers.
- Didip -