Two domains and multiple server blocks

Reinis Rozitis r at roze.lv
Sat Aug 12 12:58:20 UTC 2017


> Here, whenever I enter www.armapedia.de in my browser, I am redirected to
> armapedia.3jgkp.de. I dont understand this behavior at all. All examples about
> nginx and multiple vhosts with different domains just use the appropriate
> server_name entries, so I'm really stuck here.

First - I would try to upgrade nginx / you are using quite an old (~3 years) version 1.6.2.  

I don't particularly remember at what point but there have been some issues/changes on how nginx handles virtual server priority. At least I've seen a similar issue in serving wrong SSL certificates (as in chosing the wrong virtual server block / SNI not working as expected) which went away after upgrade to a most recent version.

While it may not be the case here it's a good point to start for a better support.



Looking at the response headers for armapedia.de:

Connecting to www.armapedia.de (www.armapedia.de)|88.99.227.139|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 301 Moved Permanently
  Server: nginx/1.6.2
  Date: Sat, 12 Aug 2017 12:48:45 GMT
  Content-Type: text/html; charset=UTF-8
  Connection: keep-alive
  Set-Cookie: wsc30_cookieHash=3fffeb677df909960a434c5f05d66f2007cde491; path=/; domain=armapedia.3jgkp.de; HttpOnly
  Location: http://armapedia.3jgkp.de/


There is a cookie for armapedia.3jgkp.de .. which means that the request is actually passed to php (also the redirect could come from php not nginx) which shouldn’t happen with:
    return 301 https://www.armapedia.de$request_uri;

what again indicates that the request is handled by the first server {} block rather than the one you expect.

rr



More information about the nginx mailing list