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