Skip to content

Instantly share code, notes, and snippets.

Last active Feb 12, 2016
What would you like to do? nginx configuration
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
# Redirect all requests to HTTPS.
return 301 https://$host$request_uri;
server {
listen 443;
listen [::]:443;
root /var/www/;
index index.php index.html index.htm /index.php;
ssl on;
ssl_certificate /etc/nginx/certs/ssl.crt;
ssl_certificate_key /etc/nginx/certs/ssl.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
# Matches everything.
location / {
try_files $uri $uri/ /index.php?$args;
autoindex on;
location ~ \.php$ {
# PHP specific config.
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;
access_log /var/log/nginx/andreagrandi.access.log;
error_log /var/log/nginx/andreagrandi.error.log;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment