nginx multiple domains (www and non-www for each domain) -
i'm trying host 2 domains on nginx server, www non-www redirection. here site configs:
site 1:
server { root /var/www/afspraken/; index index.html index.htm; server_name site1.nl; location / { proxy_pass http://127.0.0.1:8000; proxy_set_header host $host; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; } } server { server_name www.site1.nl; return 301 $scheme://site1.nl$request_uri; }
site 2:
server { root /var/www/mijn/; index index.html index.htm; server_name site2.nl; } server { server_name www.site2.nl; return 301 $scheme://site2.nl$request_uri; }
three of 4 servers work correctly: www.site2.nl
, site2.nl
, site1.nl
. www.site1.nl
server gives me site2 though. doing wrong?
found problem. servers return 301 need defined first (before servers handle redirected requests). working example:
server { server_name www.mijnbedrijfook.nl; return 301 $scheme://mijnbedrijfook.nl$request_uri; } server { root /var/www/mijn/; index index.html index.htm; server_name mijnbedrijfook.nl; }
Comments
Post a Comment