当我尝试将文件上传到我的网站时,我得到了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;在你的配置中也行.