Browse Source

Nginx: only do "no www." redirect in production

This redirect being first in the file meant that if someone tried to
access a dev version through any method except using "localhost" (such
as via the IP address), no server block would be matched, which causes
nginx to use the first one. That resulted in a 301 redirect to
tildes.net, which definitely shouldn't happen for a dev version.

This change both moves the redirect to the bottom, as well as only
adding it if it's the "prod" environment, since it's not needed in the
dev environment at all.
merge-requests/68/head
Deimos 6 years ago
parent
commit
ad4e8254bb
  1. 22
      salt/salt/nginx/tildes.conf.jinja2

22
salt/salt/nginx/tildes.conf.jinja2

@ -12,16 +12,6 @@ map $sent_http_content_type $expires_type_map {
~image/ max;
}
# redirect www. to base domain
server {
listen 80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.tildes.net;
return 301 https://tildes.net$request_uri;
}
server {
# remove trailing slash from addresses, the $port thing is a hack for
# development in Vagrant, so the port forwarding from the host is kept
@ -97,3 +87,15 @@ server {
proxy_pass http://app_server;
}
}
{% if grains["id"] == "prod" %}
# redirect www. to base domain
server {
listen 80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.tildes.net;
return 301 https://tildes.net$request_uri;
}
{% endif %}
Loading…
Cancel
Save