wordpress - Nginx Multisite Wordpress 加载资源失败:服务器响应状态为 503
问题描述
事实是我对 nginx 和多站点非常陌生。我一直在阅读指南,但今天我遇到了这个错误,它破坏了多站点的子域。
老实说,我不知道错误在哪里以及我应该如何配置它。我觉得一切都已经是一团糟了。
我知道我可以添加一个白名单,但是当我尝试输入我的 IP 时它不起作用......
这是我的 nginx.conf:
## For a live site, handling more connections, uncomment, then start WinNMP.exe --phpCgiServers=25:
worker_processes auto;
worker_rlimit_nofile 100000;
events {
## For a live site, uncomment:
worker_connections 8096;
}
http {
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
ssi off;
server_names_hash_bucket_size 64;
limit_req_zone $binary_remote_addr zone=main:10m rate=60r/m;
limit_conn_zone $binary_remote_addr zone=one:10m;
## Timeouts ##
##############
client_body_timeout 5;
client_header_timeout 5;
keepalive_timeout 25 25;
send_timeout 15s;
resolver_timeout 3s;
# Timeout period for connection with FastCGI-server. It should be noted that this value can't exceed 75 seconds.
fastcgi_connect_timeout 5s;
# Amount of time for upstream to wait for a fastcgi process to send data.
# Change this directive if you have long running fastcgi processes that do not produce output until they have finished processing.
# If you are seeing an upstream timed out error in the error log, then increase this parameter to something more appropriate.
fastcgi_read_timeout 40s;
# Request timeout to the server. The timeout is calculated between two write operations, not for the whole request.
# If no data have been written during this period then serve closes the connection.
fastcgi_send_timeout 15s;
## Buffers ##
#############
fastcgi_buffers 8 32k;
fastcgi_buffer_size 32k;
#fastcgi_busy_buffers_size 256k;
#fastcgi_temp_file_write_size 256k;
open_file_cache off;
# php max upload limit cannot be larger than this
client_max_body_size 33m;
####client_body_buffer_size 1K;
client_header_buffer_size 8k;
large_client_header_buffers 8 16k;
types_hash_max_size 2048;
include nginx.mimetypes.conf;
default_type text/html;
## Logging ##
#############
access_log "c:/winnmp/log/nginx_access.log";
error_log "c:/winnmp/log/nginx_error.log" warn; #debug or warn
log_not_found on; #enables or disables messages in error_log about files not found on disk.
rewrite_log off;
fastcgi_intercept_errors off; # Do Not Change (off) !
gzip off;
index index.php index.htm index.html;
server {
# NEVER ALLOW PUBLIC ACCESS TO THIS SERVER !!!
# Instead, create projects using WinNMP Manager, and allow public access only to those projects!
# How to allow access from LAN and Internet to your local project:
# http://WinNMP.wtriple.com/howtos.php#How-to-allow-access-from-LAN-and-Internet-to-your-local-project
listen 127.0.0.1:80 default_server; # Do Not Change ! Security Risk !
#listen [::1]:80 ipv6only=on; # Do Not Change ! Security Risk !
server_name localhost; # Do Not Change ! Security Risk !
# This directive is modified automatically by WinNMP.exe for portability.
root "c:/winnmp/www";
autoindex on;
allow 127.0.0.1; # Do Not Change ! Security Risk !
allow ::1; # Do Not Change ! Security Risk !
deny all; # Do Not Change ! Security Risk !
## deny access to .htaccess files, if Apache's document root concurs with nginx's one
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
log_not_found off;
}
location = /robots.txt {
log_not_found off;
}
## Tools are now served from include/tools/
location ~ ^/tools/.*\.php$ {
root "c:/winnmp/include";
try_files $uri =404;
include nginx.fastcgi.conf;
fastcgi_pass php_farm;
allow 127.0.0.1; # Do Not Change ! Security Risk !
allow ::1; # Do Not Change ! Security Risk !
deny all; # Do Not Change ! Security Risk !
}
location ~ ^/tools/ {
root "c:/winnmp/include";
allow 127.0.0.1; # Do Not Change ! Security Risk !
allow ::1; # Do Not Change ! Security Risk !
deny all; # Do Not Change ! Security Risk !
}
## How to add phpMyAdmin
## Copy phpMyAdmin files to c:/winnmp/include/phpMyAdmin then uncomment:
#location ~ ^/phpMyAdmin/.*\.php$ {
# root "c:/winnmp/include";
# try_files $uri =404;
# include nginx.fastcgi.conf;
# fastcgi_pass php_farm;
# allow 127.0.0.1;
# allow ::1;
# deny all;
#}
#location ~ ^/phpMyAdmin/ {
# root "c:/winnmp/include";
#}
## Notice that the root directive lacks /phpMyAdmin because Nginx adds the URL path /phpMyAdmin to the root path, so the resulting directory is c:/winnmp/include/phpMyAdmin
## PHP for localhost ##
#######################
location ~ \.php$ {
try_files $uri =404;
include nginx.fastcgi.conf;
include nginx.redis.conf;
fastcgi_pass php_farm;
allow 127.0.0.1; # Do Not Change ! Security Risk !
allow ::1; # Do Not Change ! Security Risk !
deny all; # Do Not Change ! Security Risk !
}
# How to allow access from LAN and Internet to your local project:
# http://WinNMP.wtriple.com/howtos.php#How-to-allow-access-from-LAN-and-Internet-to-your-local-project
}
include domains.d/*.conf;
include nginx.phpfarm.conf;
}
我知道错误应该是这样的:
limit_req_zone $binary_remote_addr zone=main:10m rate=30r/m;
limit_conn_zone $binary_remote_addr zone=one:10m;
但无论价值观发生多大变化,它都会继续发生。
这是我现在使用的唯一子域的 * .conf:
server {
listen 80 deferred;
listen [::]:80 deferred;
server_name mainsite.net www.mainsite.net;
return 302 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate "c:/winnmp/conf/.acmephp/master/certs/mainsite.net/public/fullchain.pem";
ssl_certificate_key "c:/winnmp/conf/.acmephp/master/certs/mainsite.net/private/key.private.pem";
root "c:/winnmp/www/mainsite";
server_name mainsite.net;
server_name www.mainsite.net;
allow all;
autoindex on;
location ~ \.php$ {
try_files $uri =404;
include nginx.fastcgi.conf;
include nginx.redis.conf;
fastcgi_pass php_farm;
fastcgi_hide_header X-Powered-By;
}
location ~ ^/wordpress/\.user\.ini {
deny all;
}
## avoid processing of calls to non-existing static files
location ~* \.(js|css|png|jpg|jpeg|gif|swf|ico|pdf|mov|fla|zip|rar|7z|tar|tgz|gz|ttf|otf|eot|swg|woff|woff2)$ {
expires 1y;
try_files $uri =404;
}
location / {
limit_req zone=main burst=10 nodelay;
fastcgi_read_timeout 80s;
fastcgi_intercept_errors off;
try_files $uri $uri/ /index.php?$args;
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# 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;
add_header Pragma "public";
add_header Cache-Control "public";
add_header Referrer-Policy "no-referrer-when-downgrade";
try_files $uri $uri/ /index.php?$args;
}
location ~ \.(html|htm|rtf|rtx|txt|xsd|xsl|xml)$ {
etag on;
if_modified_since exact;
add_header Pragma "public";
add_header Cache-Control "max-age=3600, public";
add_header Referrer-Policy "no-referrer-when-downgrade";
try_files $uri $uri/ /index.php?$args;
}
location ~ \.(asf|asx|wax|wmv|wmx|avi|avif|avifs|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|ogv|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;
add_header Pragma "public";
add_header Cache-Control "public";
add_header Referrer-Policy "no-referrer-when-downgrade";
try_files $uri $uri/ /index.php?$args;
}
add_header Referrer-Policy "no-referrer-when-downgrade";
# END W3TC Browser Cache
# BEGIN W3TC Minify core
rewrite ^/wp-content/cache/minify.*/w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1 last;
rewrite ^/wp-content/cache/minify/(.+/[X]+\.css)$ /wp-content/plugins/w3-total-cache/pub/minify.php?test_file=$1 last;
rewrite ^/wp-content/cache/minify/(.+\.(css|js))$ /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1 last;
# END W3TC Minify core
}
location /wp-login.php {
return 404;
}
location /wp-admin {
limit_conn one 10;
}
location /xmlrpc.php {
deny all;
}
}
server {
server_name subdomain.net;
location / {
return 302 https://$server_name$request_uri;
}
}
在这里我注意到我有两个配置:/wp-admin
如果不像 subdomain.net,我不用作 sub.mainsite.net 的子域。我的意思是它有自己的网址。
错误是:状态为 503,适用于所有 .js 文件,并在 Chrome 中以隐身模式出现。该网站已完全损坏。
这在没有隐身模式的 Chrome 中不会发生。同样使用 Edge,我在智能手机上的 Safari 上进行了尝试,结果它坏了。以前没有发生过。都非常难得。
这些是我在中断的子域中激活的插件:
Tawk.to Live Chat W3 Total Cache WP Cerber Security, Anti-spam & Malware Scan WP Mail SMTP Pro WP Reset WPForms Lite
我不知道我激活的最后一个插件是否是 Tawk.to Live Chat。
一切正常,我不知道还能做什么。
老实说,我不知道还要改变什么,留下什么或删除什么,以便能够很好地构建网站。我担心一切都会丢失,我将不得不从零开始。
我希望你能帮助我,希望我能正确地对我的 conf 文件进行排序。我觉得他们是一团糟。
非常感谢。
编辑:我刚刚从两个文件的边界中删除了该行。它已经正常工作了。该网站之所以没有推出,是因为它是为一所学校服务的,平均至少有 300 人会从一个拥有 2800 名用户的 Facebook 页面进入。该项目主要针对以前的学生,与学校无关。然后一切都靠我自己。我担心服务器超载,或者有人试图攻击该站点。
因此,如果存在错误,我应该在哪里放什么?在那里我完全迷失了自己。我很抱歉成为这样的新手,我提前道歉。谢谢。
解决方案
推荐阅读
- python - 全新安装的 matplotlib 中缺少 cbook
- c# - EasynetQ bus.Subscribe 未触发 - 抛出“messageType must not be null”
- powershell - 无法在 powershell 中使用 New-Volume 创建卷
- asp.net - 使用 HtmlAttributes 重载时 TextAreaFor 不起作用
- javascript - 使用 jquery 用新数据覆盖现有的 select2 多选下拉列表
- node.js - 如何从 mongodb 中的基值递增并更新许多文档
- angular5 - 根据 Angular5 中的有效令牌加载任何组件
- entity-framework - 如何使 DbContext 在 using 语句中与单元测试一起使用?
- sql - Oracle SQL 变量:SELECT 与 IN 子句中的 STRING 值列表
- c# - 使用 Open XML SDK 流式传输 Excel 数据