I have a domain and wildcard subdomains.
main domain: example.com
subdomains: s1.example.com, s2.example.com etc.
Now the requirements is
s1.example.com
will be redirect toexample.com/organization/s1
s2.example.com
will be redirect toexample.com/organization/s2
and For s1.example.com
or s2.example.com
my configuration is:
upstream frontend {
server example.com;
}
server_name ~^(?<name>.+)\.example\.com$;
location / {
proxy_pass http://frontend;
rewrite ^/$ /organization/$name break;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host example.com;
proxy_cache_bypass $http_upgrade;
}
Now I am not sure what i am missing in my config.