1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-03-21 18:37:23 +01:00

redirect all HTTP to HTTPS and enable HSTS, closes #18

This commit is contained in:
Joshua Tauberer
2014-05-14 12:15:11 +00:00
parent 091a58ac94
commit b646771517
2 changed files with 6 additions and 19 deletions

View File

@@ -1,23 +1,11 @@
# The HTTP (not SSL) server.
# Redirect all HTTP to HTTPS.
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name $PUBLIC_HOSTNAME;
# We'll expose this directory publicly over http.
root $STORAGE_ROOT/www/static;
index index.html index.htm;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
}
# Convenience redirect to https.
rewrite ^/mail(/.*)?$ https://$PUBLIC_HOSTNAME/mail$1 permanent;
root /tmp/invalid-path-nothing-here;
rewrite ^/(.*)$ https://$PUBLIC_HOSTNAME/$1 permanent;
}
# The secure HTTPS server.
@@ -31,9 +19,8 @@ server {
ssl_certificate_key $STORAGE_ROOT/ssl/ssl_private_key.pem;
include /etc/nginx/nginx-ssl.conf;
# We'll expose the same static directory under https.
# Expose this directory as static files.
root $STORAGE_ROOT/www/static;
index index.html index.htm;
# Roundcube Webmail configuration.