Skip to content

Instantly share code, notes, and snippets.

@lamnk
Created June 11, 2016 18:00
Show Gist options
  • Save lamnk/61a2db8f241e9014a1967ef21e6e35ec to your computer and use it in GitHub Desktop.
Save lamnk/61a2db8f241e9014a1967ef21e6e35ec to your computer and use it in GitHub Desktop.
Nginx virtual host config with SSL and Layer
server {
server_name www.example.com example.com;
listen 80;
return 301 https://www.example.com$request_uri;
}
server {
server_name example.com;
listen 443 ssl;
return 301 https://www.$host$request_uri;
}
server {
server_name www.example.com;
root /root/of/example.com;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_dhparam /etc/nginx/ssl/example.com/dhparams.pem;
listen 443 ssl;
charset utf-8;
access_log /var/log/nginx/example.com.log main;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
try_files $uri $uri/ /index.php;
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment