Last active
October 10, 2016 12:24
-
-
Save chrisblackwell/5051722 to your computer and use it in GitHub Desktop.
WordPress Nginx
This file contains hidden or 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
server { | |
listen 443 ssl http2; | |
server_name domain.tld; | |
root /srv/www/domain.tld/pubic; | |
# Paths to certificate files. | |
ssl_certificate /etc/ssl/ssl.com.crt; | |
ssl_certificate_key /etc/ssl/ssl.com.key; | |
# File to be used as index | |
index index.php; | |
# Overrides logs defined in nginx.conf, allows per site logs. | |
access_log /srv/www/domain.tld/logs/access.log; | |
error_log /srv/www/domain.tld/logs/error.log; | |
# Default server block rules | |
include global/server/defaults.conf; | |
# SSL rules | |
include global/server/ssl.conf; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
include global/fastcgi-params.conf; | |
# Change socket if using PHP pools | |
fastcgi_pass unix:/var/run/php7-fpm.sock; | |
} | |
} | |
# Redirect http to https | |
server { | |
listen 80; | |
server_name ssl.com www.domain.tld; | |
return 301 https://domain.tld$request_uri; | |
} | |
# Redirect www to non-www | |
server { | |
listen 443; | |
server_name www.domain.tld; | |
return 301 https://domain.tld$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment