Skip to content

Instantly share code, notes, and snippets.

@Naramsim
Last active August 29, 2015 14:22
Show Gist options
  • Save Naramsim/9929e3db1745a82d658c to your computer and use it in GitHub Desktop.
Save Naramsim/9929e3db1745a82d658c to your computer and use it in GitHub Desktop.
Nginx SSL SPDY server block
server {
listen 80 default_server;
server_name mtgfiddle.me;
return 301 https://$server_name$request_uri;
}
server {
access_log /var/log/nginx/access_log combined;
#SSL
listen 443 ssl spdy default_server;
ssl_certificate /etc/nginx/ssl/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/mtgfiddle.key;
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_dhparam /etc/ssl/private/dhparams.pem;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains"; #HSTS
server_name mtgfiddle.me;
root /usr/share/nginx/www/mtgfiddle.me;
index index.html index.php;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
##
# Pagespeed
##
pagespeed on;
pagespeed RewriteLevel CoreFilters;
pagespeed ForceCaching on;
pagespeed EnableFilters local_storage_cache;
pagespeed EnableFilters insert_ga;
pagespeed AnalyticsID UA-XX363747-1;
pagespeed MapOriginDomain "http://localhost" "https://mtgfiddle.me";
pagespeed LoadFromFile "https://mtgfiddle.me" "/usr/share/nginx/www";
pagespeed SslCertDirectory /etc/nginx/ssl;
pagespeed SslCertFile mtgfiddle_me.crt;
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/ngx_pagespeed_cache;
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
location ~* \.(jpg|jpeg|gif|png|js|css)$ {
expires 9w;
add_header Pragma public;
add_header Cache-Control "public";
}
pagespeed Statistics on;
pagespeed StatisticsLogging on;
pagespeed LogDir /var/log/pagespeed_XX;
pagespeed AdminPath /pagespeed_admin_XX;
pagespeed EnableCachePurge on;
location /nginx_status {
stub_status on;
access_log off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment