Permalinks issue (404) with NGINX and caching
-
Hi Guys,
I have an issue where pages/permalinks return a 404 on Nginx.
I have been searching high and low for the problem, and a solution to no avail.
I’ve been focussing on maximising security and performance, that when it came down to configure WordPress, I didn’t immediately notice the error, as the main page, and wp-admin works fine.
The only Plugins I’m running is:
WP Super Cache
Nginx Helper
WP Maintenance ModeFor the most part the config is good, all the SSL features and tips that I could find from several blogs and forums have been added, as well as heavy caching. I got frustrated at some point and started adding and removing stuff according to every forum post and blog entry I could find on the matter.
https://pastebin.com/Pngqu4v0:
server { listen 80; server_name www.website.co.za; return 301 https://website.co.za$request_uri; } fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; server { listen 443 ssl; listen [::]:443 ssl; #SSL + Hardening add_header Strict-Transport-Security "max-age=31536000; includeSubdomains"; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_certificate websitecozassl/bundle.cer; ssl_certificate_key websitecozassl/key.pem; root /var/www/websitecoza; server_name website.co.za; index index.php index.html; # location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. #try_files $uri $uri/ =404; # try_files $uri $uri/ /index.php?q=$uri&$args; #} ########## location ~ \.php$ { fastcgi_cache microcache; fastcgi_cache_key $scheme$host$request_uri$request_method; fastcgi_cache_valid 200 301 302 30s; fastcgi_cache_use_stale updating error timeout invalid_header http_500; fastcgi_pass_header Set-Cookie; fastcgi_pass_header Cookie; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; #try_files $uri $uri/ /index.php?q=$uri&$args; #not working } ########## 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; } #ERROR HANDLING (PAGES) # error_page 404 /404.html; # error_page 500 502 503 504 /50x.html; # root /usr/share/nginx/html; # } #Tip Copied from https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-nginx-on-ubuntu-14-04 gzip on; gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon; }
Any advice would be greatly appreciated, as I’m sure the problem is staring right at me….
- The topic ‘Permalinks issue (404) with NGINX and caching’ is closed to new replies.