Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NGINX Config with SSL Template
# NGINX CONFIG W/ SSL TEMPLATE
#dev/wordpress #dev/snippets #dev/server
```
server {
listen 80;
listen [::]:80;
server_name www.example.com;
return 301 https://$host$request_uri;
}
server {
listen 80;
listen [::]:80;
server_name staging.example.com example.com;
return 301 https://www.example.com$request_uri;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
client_max_body_size 20M;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name www.example.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
location ~ /\.ht {
deny all;
}
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment