Nginx 多站点 Wordpress 加载资源失败:服务器响应状态为 503

如何解决Nginx 多站点 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

我不用作 sub.mainsite.net 的子域,如果不是像 subdomain.net。我的意思是它有自己的网址。

错误是:状态为 503,适用于所有 .js 文件,并在 Chrome 中以隐身模式出现。而且该网站已完全损坏。

在没有隐身模式的 Chrome 中不会发生这种情况。同样使用 Edge,我在智能手机上的 Safari 中尝试过,结果发现它坏了。以前没有发生过。非常罕见。

这些是我在中断的子域中激活的插件:

Tawk.to 实时聊天 W3 总缓存 WP Cerber 安全、反垃圾邮件和恶意软件扫描 WP 邮件 SMTP 专业版 WP 重置 WPForms 精简版

我不知道是不是 Tawk.to Live Chat 是我激活的最后一个插件。

一切正常,我不知道还能做什么。

老实说,我不知道还有什么要改变,要留下什么或要删除什么,以便能够很好地构建网站。我害怕一切都会失去,我将不得不从零开始。

我希望你能帮助我,希望我能正确地整理我的 conf 文件。我觉得他们一团糟。

非常感谢。

编辑:我刚刚从两个文件的边界中删除了该行。它已经正常工作。该网站不是因为它是为一所学校而推出的,平均至少有 300 人会从一个拥有 2800 名用户的 Facebook 页面进入。该项目主要面向以前的学生,与学校无关。然后一切都靠我自己了。我担心的是服务器过载,或者有人试图攻击该站点。

所以如果出现错误,我应该放什么,放在哪里?在那里我完全迷失了自己。我很抱歉成为这样的新手,我提前道歉。谢谢。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)> insert overwrite table dwd_trade_cart_add_inc > select data.id, > data.user_id, > data.course_id, > date_format(
错误1 hive (edu)> insert into huanhuan values(1,'haoge'); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive> show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 <configuration> <property> <name>yarn.nodemanager.res