Added a https www-to-non-www redirect.

This commit is contained in:
Martin Mahner 2013-06-05 20:44:31 +02:00
parent f6f04901d6
commit 9b1d06a919

View file

@ -2,11 +2,14 @@ upstream app_server {
server 127.0.0.1:12000 fail_timeout=0;
}
# -----------------------------------------------------------------------------
# Redirect all sort of non-ssl (with and without www) to ssl without www
# -----------------------------------------------------------------------------
server {
listen 80;
server_name dpaste.de dpaste.org;
# Do not redirect to SSL for API calls (some clients dont support
server_name dpaste.de www.dpaste.de dpaste.org www.dpaste.org;
# Do not redirect to SSL for API calls (some clients dont support
# this automatically)
location /api {
include /srv/dpaste.de/src/dpaste/server/nginx_server_appforward.conf;
@ -17,6 +20,9 @@ server {
}
}
# -----------------------------------------------------------------------------
# SSL Hosts
# -----------------------------------------------------------------------------
server {
listen 443;
server_name dpaste.de;
@ -25,6 +31,12 @@ server {
ssl_certificate /srv/dpaste.de/var/ssl/dpaste_de_unified.crt;
ssl_certificate_key /srv/dpaste.de/var/ssl/dpaste_de.key;
# Rewrite www to non-www
if ($host ~ /^www\./) {
rewrite ^/(.*)$ https://dpaste.de/$1 permanent;
}
add_header Strict-Transport-Security max-age=25200;
include /srv/dpaste.de/src/dpaste/server/nginx_server.conf;
@ -33,12 +45,17 @@ server {
server {
listen 443;
server_name dpaste.org;
ssl on;
ssl_certificate /srv/dpaste.de/var/ssl/dpaste_org_unified.crt;
ssl_certificate_key /srv/dpaste.de/var/ssl/dpaste_org.key;
add_header Strict-Transport-Security max-age=25200;
# Rewrite www to non-www
if ($host ~ /^www\./) {
rewrite ^/(.*)$ https://dpaste.org/$1 permanent;
}
include /srv/dpaste.de/src/dpaste/server/nginx_server.conf;
}