Hello, I built a Nginx server that hosts WordPress. (Nginx version:1.23.2 PHP:7.4.33 MySQL:10.3.28 MariaDB)
WordPress hosts about 110 users (not at once) and cannot access to the web.
site worked perfectly until I update the Centos and after that i got Error **ERR_EMPTY_RESPONSE**
I know what might be the Problem just don't know where to look.
This is the issue that I found so far:
When Nginx Cache Plugin purge the Cache (only When I made change to the [site) I Get "ERR_EMPTY_RESPONSE"
Because the Cache folder stays empty after purge (this is the problem i found after I didn't do any changes in server config)
However when I restart Nginx. files will be written to the Cache folder and site works again until next purge.
I put my configs down blow.
nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
client_max_body_size 128M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
# enables GZIP compression
gzip on;
# compression level (1-9)
# 6 is a good compromise between CPU usage and file size
gzip_comp_level 5;
# minimum file size limit in bytes to avoid negative compression outcomes
gzip_min_length 256;
# compress data for clients connecting via proxies
gzip_proxied any;
# directs proxies to cache both the regular and GZIP versions of an asset
gzip_vary on;
# disables GZIP compression for ancient browsers that don't support it
gzip_disable "msie6";
# compress outputs labeled with the following file extensions or MIME-types
# text/html MIME-type is enabled by default and need not be included
gzip_types
application/atom+xml
application/geo+json
application/javascript
application/x-javascript
application/json
application/ld+json
application/manifest+json
application/rdf+xml
application/rss+xml
application/vnd.ms-fontobject
application/wasm
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/eot
font/otf
font/ttf
image/bmp
image/svg+xml
text/cache-manifest
text/calendar
text/css
text/javascript
text/markdown
text/plain
text/xml
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
server {
listen 80;
listen [::]:80;
server_tokens off;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
site config file
`fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHZONE:100m inactive=60m max_size=5g;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server {
listen 80;
server_name intranet.saipalogistics.ir;
root /sites/interanet.saipalogistics.ir/public_html/;
index index.html index.php;
access_log /sites/interanet.saipalogistics.ir/logs/access.log;
error_log /sites/interanet.saipalogistics.ir/logs/error.log;
# BEGIN WebP Converter
set $ext_avif ".avif";
if ($http_accept !~* "image/avif") {
set $ext_avif "";
}
set $ext_webp ".webp";
if ($http_accept !~* "image/webp") {
set $ext_webp "";
}
location ~ /wp-content/(?<path>.+)\.(?<ext>jpe?g|png|gif|webp)$ {
add_header Vary Accept;
add_header Cache-Control "private" always;
expires 365d;
try_files
/wp-content/uploads-webpc/$path.$ext$ext_avif
/wp-content/uploads-webpc/$path.$ext$ext_webp
$uri =404;
}
# END WebP Converter
# Don't allow pages to be rendered in an iframe on external domains.
add_header X-Frame-Options "SAMEORIGIN";
# MIME sniffing prevention
add_header X-Content-Type-Options "nosniff";
# Enable cross-site scripting filter in supported browsers.
add_header X-Xss-Protection "1; mode=block";
# Prevent access to hidden files
location ~* /\.(?!well-known\/) {
deny all;
}
# Prevent access to certain file extensions
location ~\.(ini|log|conf)$ {
deny all;
}
# Enable WordPress Permananent Links
location / {
try_files $uri $uri/ /index.php?$args;
}
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/*|/tag/.*/feed/*|index.php|/.*sitemap.*\.(xml|xsl)") {
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;
}
#for plugin that perevents direct access to files
#Put our rewrite rules here, i.e.
rewrite wp-content/uploads(/_pda/.*\.\w+)$ "/index.php?pda_v3_pf=$1" last;
rewrite private/([a-zA-Z0-9-_]+)$ "/index.php?pda_v3_pf=$1&pdav3_rexypo=ymerexy" last;
location ~ \.php$ {
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_cache_min_uses 3;
fastcgi_cache_revalidate on;
fastcgi_cache_background_update on;
fastcgi_cache_lock on;
fastcgi_cache CACHZONE;
fastcgi_cache_valid 60m;
add_header X-Cache $upstream_cache_status;
}
}
`
I solved the problem by disabling fastcgi cache and i turned the site cache on. its not that fast but it gets the job done.
nginx new update has compability problem with fastcgi cache
Hello, I built a Nginx server that hosts WordPress. (Nginx version:1.23.2 PHP:7.4.33 MySQL:10.3.28 MariaDB)
WordPress hosts about 110 users (not at once) and cannot access to the web.
I know what might be the Problem just don't know where to look.
This is the issue that I found so far:
When Nginx Cache Plugin purge the Cache (only When I made change to the [site) I Get "ERR_EMPTY_RESPONSE" Because the Cache folder stays empty after purge (this is the problem i found after I didn't do any changes in server config)
However when I restart Nginx. files will be written to the Cache folder and site works again until next purge.
I put my configs down blow.
nginx.conf
site config file