[乐意黎] 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:

1. 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路径

解决:

1. 在 Server 定义了 root 路径



2. 修改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 为网站的根目录

3. 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;
}

乐意黎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值