[乐意黎] Nginx 出现 "The connection was reset" 以及 "file not found" 等问题的解决方法
一、抛 The connection was reset 错误
get an error that says “The connection was reset” immediately when I upload a file over a certain size, I think it’s over around 4MB.
My web server is running on nginx, I tried set client_max_body_size 1G
or even setting to 0, no success.
I’d be glad to hear a solution.
Thanks!
Answer:
- I just had to restart the nginx service by using “
sudo service nginx restart"
and it solved itself!
2.In my case, the file was bigger than the allowed size by NGINX
in the setting “client_max_body_size
“. To change this setting open in your terminal the file /etc/nginx/nginx.conf and add the following inside the http section:
nginx.conf里修改并添加 client_max_body_size 项
http {
...
client_max_body_size 128m; #Any desired size in MB
...
}
In nginx versions from 1.0 and above, this setting is not included by default in the nginx.conf file.
二、 “file not found”的问题
问题原因:未在Localtion 中里定义网站根目录 root路径
解决:
- 在 Server 定义了 root 路径
修改location里的 fastcgi_param SCRIPT_FILENAME 的值
fastcgi_param SCRIPT_FILENAME scripts$fastcgi_script_name;
解决办法:改成
fastcgi_param SCRIPT_FILENAME /usr/wwwroot/site$fastcgi_script_name;
其 /usr/wwwroot/site 为网站的根目录
location 项内容如下:
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/wwwroot/site$fastcgi_script_name;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_buffer_size 64K;
fastcgi_buffers 256 64k;
include fastcgi_params;# for 404
fastcgi_intercept_errors on;
}
乐意黎
还没有评论,来说两句吧...