How can I configure nginx to rewrite <somesubdomain>.mydomain.com to mydomain.com/some/url/path/<somesubdomain>/?
somesubdomain is a wildcard subdomain.
The main requirement is NOT REDIRECT, <somesubdomain>.mydomain.com should be a mask for mydomain.com/some/url/path/<somesubdomain>/.
Also, accessing other urls different from / (like somesubdomain.mydomain.com/test/) should not show anything.
Please note that I have a proxy for / configured for mydomain.com, so /some/url/path/<somesubdomain>/ should be passed and resolved by server which is proxied:
location / {
proxy_pass http://app_servers;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_connect_timeout 10;
proxy_read_timeout 10;
}