Last active
February 4, 2018 23:56
-
-
Save mattpatterson94/d6c82eacdef980eef87316a5369b6b22 to your computer and use it in GitHub Desktop.
NGINX Config with SSL Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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