【发布时间】:2011-05-20 22:21:35
【问题描述】:
当我尝试将文件上传到我的站点时,我收到 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 /上传 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/*;
}
以及网站的虚拟主机:
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 配置设置
标签: php file-upload nginx