WordPress和NGINX 413上传

时间:2019-01-29 11:32:18

标签: php wordpress nginx php-7.2

好吧,这似乎是一个非常容易回答,直截了当和问了一百遍的问题,但是如果网上有解决我的问题的答案,我会在前面的文章中找到5(!)天的彻底研究和失败的尝试。

当我尝试在WordPress中上载稍大的文件(最多约8-10 MB的作品,但不一定是每个文件)时,NGINX出现413错误。我所做的:

  1. (执行一次干净的WP安装约4次)
  2. 已检查的目录权限
  3. 在任何地方都更改了client_max_body_size(甚至在我的服务器上执行了全文搜索,实际上几乎在任何地方都对其进行了更改;甚至在所有地方都将其设置为0以完全暂时禁用限制)
  4. 更改了PHP配置值(是的,我确保它是正确的php.ini,是的,它已正确加载)
  5. 试图添加client_body_in_file_only clean; client_body_buffer_size 32K;
  6. 确保NGINX日志中没有错误...(确实没有)
  7. 已检查PHP FPM设置

是的,每次对配置进行任何更改时,我都确实重新启动了NGINX和PHP(PHP7.2-FPM)。我已经搜查了几个小时,现在仍然不知道该怎么办...我所做的甚至比平时运行它所需的更多...更不用说我的Laravel内一切都很好了服务器上的应用程序(我也上传了较大的文件)...我真的开始怀疑自己...这是我的nginx.conf:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        client_max_body_size 0;
        client_body_in_file_only clean;
        client_body_buffer_size 32K;

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

这是我的NGINX服务器配置文件(是的,我确保已正确加载它):

upstream php {
        server unix:/var/run/php/php7.2-fpm.sock;
        server 127.0.0.1:9000;
}
server {
        root /var/www/wp;
        index index.php;
        server_name www.example.com example.com;
        client_max_body_size 0;

        location / {
              client_max_body_size 0;
              try_files $uri $uri/ /index.php$is_args$args;
        }
        location ~ \.php$ {
                client_max_body_size 0;
                include snippets/fastcgi-php.conf;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
                fastcgi_connect_timeout 300s;
                fastcgi_read_timeout 300s;
                fastcgi_send_timeout 300s;
        }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    client_max_body_size 0;
    if ($scheme != https) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    server_name example.com www.example.com;
    listen 80;
    return 404; # managed by Certbot
}

好吧...希望有一个技巧可以解决这个问题...我好绝望...:-/

编辑:这是实时HTTP标头输出(已删除cookie的确切内容)

POST /wp-admin/admin-ajax.php HTTP/1.1
Host: www.example.com:443
Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Cookie: wordpress_sec_f828006c09c634a9c87995108de4c055=xxxx; wp-settings-time-1=xxxx; spcsrf=xxxx;andsomemorecookieshere
Origin: https://www.example.com
Referer: https://www.example.com/wp-admin/upload.php
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
X-Requested-With: XMLHttpRequest

HTTP/1.1 200
access-control-allow-credentials: true
access-control-allow-origin: https://www.example.com
access-control-allow-origin: *
cache-control: no-cache, must-revalidate, max-age=0
content-type: application/json; charset=UTF-8
date: Tue, 29 Jan 2019 11:36:35 GMT
expires: Wed, 11 Jan 1984 05:00:00 GMT
referrer-policy: strict-origin-when-cross-origin
server: fbs
set-cookie: spcsrf=cf0870b291b52a7c657c5d3f098b8f6f; Expires=Tue, 29-Jan-19 13:36:35 GMT; Path=/; HttpOnly; SameSite=Strict
status: 200
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-hw: 1548761795.cds116.fr8.hc,1548761795.cds105.fr8.sc,1548761795.cdn2-wafbe01-fra1.stackpath.systems.-.wx,1548761795.cds105.fr8.p
x-robots-tag: noindex

我还要进一步提到,此特定页面在StackPath的WAF(包括CDN等)后面运行。但是,我不会找到任何参数来更改要传输的最大允许大小(或类似值)的任何内容,或者Google搜索“ StackPath WAF 413”或“ WAF 413”都不会返回任何有用的结果。

0 个答案:

没有答案
相关问题