Created
July 5, 2018 09:44
-
-
Save hrmon/2dbd4df7434b08fdf8a325e2f9a4a1d1 to your computer and use it in GitHub Desktop.
Nginx with Let's Encrypt Certificate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Advanced config for NGINX | |
server_tokens off; | |
add_header X-XSS-Protection "1; mode=block"; | |
add_header X-Content-Type-Options nosniff; | |
# Redirect all HTTP traffic to HTTPS | |
server { | |
listen 80; | |
server_name www.example.com example.com; | |
return 301 https://$host$request_uri; | |
} | |
# SSL configuration | |
server { | |
listen 443 ssl default deferred; | |
server_name www.example.com example.com; | |
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem; | |
# Improve HTTPS performance with session resumption | |
ssl_session_cache shared:SSL:10m; | |
ssl_session_timeout 5m; | |
# Enable server-side protection against BEAST attacks | |
ssl_prefer_server_ciphers on; | |
ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5; | |
# Disable SSLv3 | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
# Diffie-Hellman parameter for DHE ciphersuites | |
# $ sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 4096 | |
ssl_dhparam /etc/ssl/certs/dhparam.pem; | |
# Enable HSTS (https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security) | |
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains"; | |
# Enable OCSP stapling (http://blog.mozilla.org/security/2013/07/29/ocsp-stapling-in-firefox) | |
ssl_stapling on; | |
ssl_stapling_verify on; | |
ssl_trusted_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem; | |
resolver 8.8.8.8 8.8.4.4 valid=300s; | |
resolver_timeout 5s; | |
# Required for LE certificate enrollment using certbot | |
location '/.well-known/acme-challenge' { | |
default_type "text/plain"; | |
root /var/www/html; | |
} | |
location / { | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment