Skip to content

Instantly share code, notes, and snippets.

@genio
Last active February 24, 2021 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save genio/6405b785fc763270c262 to your computer and use it in GitHub Desktop.
Save genio/6405b785fc763270c262 to your computer and use it in GitHub Desktop.
nginx conf
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_protocols TLSv1.2 TLSv1.1;
ssl_certificate /etc/pki/tls/certs/star_example.crt;
ssl_certificate_key /etc/pki/tls/private/example_com_no_pass.key;
ssl_dhparam /etc/pki/tls/certs/dhparams.pem;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.4.4 8.8.8.8 valid=300s;
resolver_timeout 10s;
ssl_session_cache shared:SSL:32m;
ssl_buffer_size 8k;
ssl_session_timeout 10m;
server {
listen 80;
server_name www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 deferred ssl http2;
server_name www.example.com;
keepalive_timeout 60;
add_header Strict-Transport-Security max-age=31536000;
# add_header Public-Key-Pins 'pin-sha256="<public_key_pin_fingerprint_here>"; max-age=5184000; includeSubDomains';
location / {
root html;
index index.html;
}
}
@genio
Copy link
Author

genio commented May 21, 2015

To get your Public Key Pin base-64 encoded fingerprint, use the command below and replace the Public-Key-Pins header info with the output from this command.

openssl rsa -in /etc/pki/tls/private/example_com_no_pass.key -outform der -pubout | openssl dgst -sha256 -binary | openssl enc -base64

Note that Public Key Pins can cause problems if you need to revoke your cert and you don't have more than one cert pinned (IE a backup cert). For this reason, I recommend against it.

@genio
Copy link
Author

genio commented May 21, 2015

To get your dhparams.pem file, you run one command

openssl dhparam -out /etc/pki/tls/certs/dhparams.pem 2048

@genio
Copy link
Author

genio commented Jun 11, 2015

To setup a reverse proxy instead of serving HTML, change the location section in the above config to this:

location / {
    proxy_pass https://<your_domain>.com;
    proxy_set_header Host <your_domain>.com;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment