Skip to content

Instantly share code, notes, and snippets.

@fredead
Last active January 13, 2017 12:16
Show Gist options
  • Save fredead/030250a58793769618b6f114d0cc2406 to your computer and use it in GitHub Desktop.
Save fredead/030250a58793769618b6f114d0cc2406 to your computer and use it in GitHub Desktop.
Nginx port 80 to port 443 redirect with added ssl hardening
server {
listen 80;
server_name www.loaders.net;
rewrite ^ https://$server_name$request_uri? permanent;
#listen 80 default_server;
#return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name www.loaders.net;
# These values are designed to give a A+ pass on https://www.ssllabs.com/ssltest/
ssl_certificate /etc/nginx/wildcard.loaders.net.crt;
ssl_certificate_key /etc/nginx/wildcard.loaders.net.key;
# Can add SSLv3 for IE 6 but this opens up to poodle
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# reduction to only the best ciphers
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_stapling on;
# Special 4096 random number generate by
# openssl dhparam -out /etc/nginx/dhparam.pem 4096
ssl_dhparam /etc/nginx/dhparam.pem;
location / {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto "https";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment