Last active
February 15, 2017 15:10
-
-
Save A5hleyRich/d911a709124c83164b64 to your computer and use it in GitHub Desktop.
Hosting WordPress Yourself Part 7
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
fastcgi_cache_path /home/ashley/ashleyrich.com/cache levels=1:2 keys_zone=ashleyrich.com:100m inactive=60m; | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name pluto.ashleyrich.com; | |
ssl_certificate /etc/letsencrypt/live/pluto.ashleyrich.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/pluto.ashleyrich.com/privkey.pem; | |
access_log /home/ashley/ashleyrich.com/logs/access.log; | |
error_log /home/ashley/ashleyrich.com/logs/error.log; | |
root /home/ashley/ashleyrich.com/public/; | |
index index.php; | |
set $skip_cache 0; | |
# POST requests and urls with a query string should always go to PHP | |
if ($request_method = POST) { | |
set $skip_cache 1; | |
} | |
if ($query_string != "") { | |
set $skip_cache 1; | |
} | |
# Don't cache uris containing the following segments | |
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") { | |
set $skip_cache 1; | |
} | |
# Don't use the cache for logged in users or recent commenters | |
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { | |
set $skip_cache 1; | |
} | |
# Don't cache shopping basket, checkout or account pages | |
if ($request_uri ~* "/cart/*$|/checkout/*$|/my-account/*$") { | |
set $skip_cache 1; | |
} | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php7.1-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_cache_bypass $skip_cache; | |
fastcgi_no_cache $skip_cache; | |
fastcgi_cache ashleyrich.com; | |
fastcgi_cache_valid 60m; | |
} | |
} | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name pluto.ashleyrich.com; | |
return 301 https://$server_name$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment