加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Nginx错误413

发布时间:2020-12-13 14:02:57 所属栏目:PHP教程 来源:网络整理
导读:当我尝试将文件上传到我的网站时,我得到了Nginx“413请求实体太大”的错误,但是在我的nginx.conf文件中,我已经明确地将最大大小约为250MB,并更改了php.ini中的最大文件大小(是的,我重新启动了进程).错误日志告诉我: 2010/12/06 04:15:06 [error] 20124#0: *
当我尝试将文件上传到我的网站时,我得到了Nginx“413请求实体太大”的错误,但是在我的nginx.conf文件中,我已经明确地将最大大小约为250MB,并更改了php.ini中的最大文件大小(是的,我重新启动了进程).错误日志告诉我:

2010/12/06 04:15:06 [error] 20124#0:
*11975 client intended to send too large body: 1144149 bytes,client:
60.228.229.238,server: www.x.com,request: “POST
/upload HTTP/1.1”,host:
“x.com”,referrer:
“http://x.com/”

据我所知,1144149字节不是250MB …
有没有我在这里失踪的东西?

这是Nginx的基本配置:

user  nginx;
worker_processes  8;
worker_rlimit_nofile 100000;

error_log   /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
    use epoll;
}


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

    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;
    client_max_body_size 300M;
    tcp_nopush      on;
    tcp_nodelay     on;
    server_tokens   off;
    gzip            on;
    gzip_static     on;
    gzip_comp_level 5;
    gzip_min_length 1024;
    keepalive_timeout  300;
    limit_zone   myzone  $binary_remote_addr  10m;

    # Load config files from the /etc/nginx/conf.d directory
    include /etc/nginx/sites/*;
}

和网站的vhost:

server {
    listen      80;
    server_name www.x.com x.com;

    access_log  /var/log/nginx/x.com-access.log;

    location / {
        index   index.html index.htm index.php;
        root    /var/www/x.com;

        if (!-e $request_filename) {
            rewrite ^/([a-z,0-9]+)$/$1.php last;
            rewrite ^/file/(.*)$/file.php?file=$1;
        }

        location ~ /engine/.*.php${
            return 404;
        }

        location ~ ^/([a-z,0-9]+).php${
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include     fastcgi_params;
        }
    }
}
不知道您的nginx版本的版本以及它们所构建的模块是如何变得非常困难的,但请尝试以下操作:

>复制你的client_max_body_size 300M;进入vhost配置的位置/ {}部分.我不知道它是否正确覆盖了默认值(1 MB).
你使用nginx_upload_module吗?如果是,请确保你有upload_max_file_size 300MB;在你的配置中也行.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读