Skip to content

Instantly share code, notes, and snippets.

@ChengLong
Last active June 6, 2016 06:04
Show Gist options
  • Save ChengLong/47a9ceff0480af0ada2e to your computer and use it in GitHub Desktop.
Save ChengLong/47a9ceff0480af0ada2e to your computer and use it in GitHub Desktop.
Nginx HTTPS config with Let's Encrypt, HTTP/2 and HTTP redirect
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name domain.com www.domain.com;
ssl on;
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_dhparam /etc/dhparams.pem;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
ssl_stapling on;
ssl_stapling_verify on;
access_log /var/log/nginx/domain.com.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:2368;
proxy_redirect off;
}
root /usr/share/nginx/html;
location ~ /.well-known {
allow all;
}
}
server {
listen 80;
listen [::]:80;
server_name domain.com www.domain.com;
return 301 https://$host$request_uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment