Nginx错误413

EJa*_*Jay 14 php file-upload nginx

当我尝试将文件上传到我的网站时,我收到的是Nginx"413 Request Entity Too Large"错误,但是在我的nginx.conf文件中,我已经明确说明目前最大大小约为250MB,并改变了php.ini中的最大文件大小(是的,我重新启动了进程).错误日志给了我这个:

2010/12/06 04:15:06 [错误] 20124#0:*11975客户端意图发送过大的机身:1144149字节,客户端:60.228.229.238,服务器:www.x.com,请求:"POST/upload HTTP/1.1",主机:"x.com",推荐人:"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/*;
}
Run Code Online (Sandbox Code Playgroud)

和网站的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;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

A. *_*nce 15

不知道你的nginx版本的版本以及它构建的模块使这很难,但请尝试以下方法:

  1. 复制client_max_body_size 300M; 进入vhost配置的位置/ {}部分.我不确定它是否正确覆盖了默认值(即1 MB).

  2. 你在用nginx_upload_module吗?如果是这样,请确保upload_max_file_size为300MB; 你的配置也行.