W3tc Nginx 404 problem config
-
Hello,
I am using Nginx 1.19.3, WordPress 5.5.1, W3tc 0.15.0, mysql 8(AWS RDS) On Ubuntu 20.04 (AWS EC2).I am Getting 404 error on posts and page, but Front page loads just fine. whenever I am enabling Minify.
NGINX CONFIG
#user www-data; error_log /var/log/nginx/error.log; events { worker_connections 2048; } http { include mime.types; default_type application/octet-stream; #access_log logs/access.log; client_max_body_size 100m; #include blockedip.conf; server_tokens off; #sendfile on; #tcp_nopush on; keepalive_timeout 300; #gzip on; #gzip_min_length 200; #gzip_comp_level 6; #gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon image/png image/gif image/jpeg image/jpg; #gzip_disable "msie6"; #gzip_vary on; fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; server { listen 80; root /var/www/site/; index index.php; server_name myexamplesite.com www.myexamplesite.com; location / { try_files $uri $uri/ /index.php?$args; include /var/www/site/*.conf; } access_log /var/log/nginx/access.log; location ~ \.php$ { #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini include fastcgi.conf; #try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; include fastcgi_params; fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9000; fastcgi_buffers 16 64k; fastcgi_buffer_size 64k; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; } } }
W3TC config
# BEGIN W3TC Minify cache location ~ /wp-content/cache/minify/.*js_gzip$ { gzip off; types {} default_type application/x-javascript; add_header Content-Encoding gzip; expires 31536000s; etag on; if_modified_since exact; add_header Referrer-Policy "no-referrer-when-downgrade"; add_header Vary "Accept-Encoding"; } location ~ /wp-content/cache/minify/.*css_gzip$ { gzip off; types {} default_type text/css; add_header Content-Encoding gzip; expires 31536000s; etag on; if_modified_since exact; add_header Referrer-Policy "no-referrer-when-downgrade"; add_header Vary "Accept-Encoding"; } # END W3TC Minify cache # BEGIN W3TC Browser Cache gzip on; gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon application/json application/vnd.ms-access video/webm application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint image/svg+xml application/x-shockwave-flash image/tiff application/x-font-ttf audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel; location ~ \.(css|htc|less|js|js2|js3|js4)$ { expires 31536000s; etag on; if_modified_since exact; try_files $uri $uri/ /index.php?$args; } location ~ \.(html|htm|rtf|rtx|txt|xsd|xsl|xml)$ { etag on; if_modified_since exact; try_files $uri $uri/ /index.php?$args; } location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|webp|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|webm|mpp|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|_ttf|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$ { expires 31536000s; etag on; if_modified_since exact; try_files $uri $uri/ /index.php?$args; } add_header Referrer-Policy "no-referrer-when-downgrade"; # END W3TC Browser Cache # BEGIN W3TC Minify core set $w3tc_enc ""; if ($http_accept_encoding ~ gzip) { set $w3tc_enc _gzip; } if (-f $request_filename$w3tc_enc) { rewrite (.*) $1$w3tc_enc break; } rewrite ^/wp-content/cache/minify/ /index.php last; # END W3TC Minify core
I have stripped Down To minimum functions (removed SSL and all) but still I am getting the 404 rerror.
But I have tested again & again and found out that the three lines near end.
if ($http_accept_encoding ~ gzip) { set $w3tc_enc _gzip; }
those above three line when removed or commented out then I am not getting that error.
But maybe It will block some functionality of my site too.
So I want to know the solution of it.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘W3tc Nginx 404 problem config’ is closed to new replies.