Skip to content

Instantly share code, notes, and snippets.

@mrofi
Created June 2, 2016 21:06
Show Gist options
  • Save mrofi/9c9b64f9a112adbd4b6304fce9213bf4 to your computer and use it in GitHub Desktop.
Save mrofi/9c9b64f9a112adbd4b6304fce9213bf4 to your computer and use it in GitHub Desktop.
NGINX Server Block
#BLOCKNAME
server {
listen 80;
server_name servername.com;
return 302 https://$server_name$request_uri;
}
server {
# listen 80;
listen 443 ssl;
server_name servername.com;
root /path/to/www;
location ~ /.well-known {
allow all;
}
ssl_certificate /etc/letsencrypt/live/servername.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/servername.com/privkey.pem;
access_log /var/log/nginx/servername.access.log;
error_log /var/log/nginx/servername.error.log;
include /etc/nginx/index.php.conf;
include /etc/nginx/ssl.conf;
}
index index.php index.html index.htm;
client_max_body_size 128M;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_read_timeout 600;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
ssl_dhparam /etc/ssl/dh.pem;
ssl on;
#enables all versions of TLS, but not SSLv2 or 3 which are weak and now deprecated.
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
#Disables all weak ciphers
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security max-age=15768000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment