Skip to content

Instantly share code, notes, and snippets.

@granbom
Last active January 20, 2018 15:32
Show Gist options
  • Save granbom/c0071370844540def379593a3cf5ed00 to your computer and use it in GitHub Desktop.
Save granbom/c0071370844540def379593a3cf5ed00 to your computer and use it in GitHub Desktop.
server {
listen 80;
server_name example.com www.example.com;
access_log off;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
access_log off;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
access_log /var/log/nginx/example.com.log;
# see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
# and https://hstspreload.org/
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
root /var/www/example.com/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment