I have setup an nginx proxy with a couple of servers behind it, also
running
nginx.
For the most part everything works nicely, although I have a strange
issue.
I have my domains setup with a wildcard CNAME record so any subdomain
should
work.
I have a couple of vhosts setup intitially domain1.com and domain2.com
which
work fine.
I have tried to redirect any requests from sub domains of these 2
domains as
follows:
server {
listen 80;
server_name .domain1.com;
rewrite ^/(.)$ http://domain1.com/$1 permanent;
}
I also tried using a check against the hostname.
The problem is the redirect works for domain1.com, but not for
domain2.com,
any request to something.domain2.com is redirected to domain1.com.
Can anyone help resolve this?
Thanks
Phil.