今天有同事找我,说图片上传之后,不知道去哪里了。分析了一下问题,找到原因之后做了处理,这里简要记录一下。

问题原因:

1.首先后台log并无错误信息;

2.捡查了一下浏览器,发现network中有报错,413 Request Entity Too Large,但前台未报错。

解决办法:

1.备份Nginx配置文件;(个人习惯,免得修改之后,如果需要还原,忘记原来的配置)

2.查看当前Nginx配置文件:

[root@VM_0_16_centos nginx]# cat nginx.conf | grep client_max_body_size

client_max_body_size    10m;

client_max_body_size    10m;

client_max_body_size    10m;

client_max_body_size    10m;

client_max_body_size    10m;

client_max_body_size    10m;

client_max_body_size    10m;

client_max_body_size    10m;

结果发现涉及到很多项目,继续查询

cat /etc/nginx/nginx.conf | grep -C  client_max_body_size

得到结果如下:

[root@VM_0_16_centos nginx]# cat /etc/nginx/nginx.conf | grep -C  client_max_body_size
# Load configuration files for the default server block.
#include /etc/nginx/default.d/*.conf; location ^~ /b1/ {
proxy_pass http://b1_server/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Connection close;
proxy_connect_timeout 5000ms;
# client_max_body_size 10m; access_log /logs/nginx/access_api_b1.log main;
error_log /logs/nginx/error_api_b1.log info;
} location ^~ /bn/ {
proxy_pass http://bn_server/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Connection close;
proxy_connect_timeout 5000ms;
# client_max_body_size 10m; access_log /logs/nginx/access_api_bn.log main;
error_log /logs/nginx/error_api_bn.log info;
} # 由于boss程序中web路径已经带/boss前缀,所以proxy_pass不能带/后缀,后续再调整,切记切记!
location ^~ /boss/ {
proxy_pass http://boss_server;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Connection close;
proxy_connect_timeout 5000ms;
# client_max_body_size 10m; access_log /logs/nginx/access_api_boss.log main;
error_log /logs/nginx/error_api_boss.log info;
} location ^~ /detector/ {
proxy_pass http://detector_server/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Connection close;
proxy_connect_timeout 5000ms;
client_max_body_size 10m; access_log /logs/nginx/access_api_detector.log main;
error_log /logs/nginx/error_api_detector.log info;
} location ^~ /sales/ {
proxy_pass http://sales_server/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Connection close;
proxy_connect_timeout 5000ms;
# client_max_body_size 10m; access_log /logs/nginx/access_api_sales.log main;
error_log /logs/nginx/error_api_sales.log info;
} location ^~ /qn/prv/ {
proxy_pass http://private.haochuang.cn/;
} location ^~ /qn/pub/ {
--
error_log /logs/nginx/error_admin_boss.log info;
} location ^~ /boss/ {
proxy_pass http://boss_server;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Connection close;
proxy_connect_timeout 5000ms;
# client_max_body_size 10m; access_log /logs/nginx/access_api_boss.log main;
error_log /logs/nginx/error_api_boss.log info;
} location ^~ /stats/ {
proxy_pass http://stats_server;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Connection close;
proxy_connect_timeout 5000ms;
client_max_body_size 10m; access_log /logs/nginx/access_api_stats.log main;
error_log /logs/nginx/error_api_stats.log info;
} location ^~ /qn/prv/ {
proxy_pass http://private.haochuang.cn/;
    }

3.修改配置文件:

location / {
root html;
index index.html index.htm;
client_max_body_size 1000m;
}

修改client_max_body_size 配置:

server
{
listen ;
server_name chat.erp.360buy.com;
#access_log /export/servers/nginx/logs/chat.erp.360buy.com;
location / {
proxy_pass http://tomcat;
client_max_body_size 10m; #表示最大上传10M,需要多大设置多大。
} }

3.重新加载配置文件,并重新加载nginx:

[root@VM_0_16_centos nginx]# /usr/sbin/nginx  -c /etc/nginx/nginx.conf

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)

nginx: [emerg] still could not bind()

[root@VM_0_16_centos nginx]# /usr/sbin/nginx  -s reload

4.如果还未生效,重启nginx:

[root@VM_0_16_centos nginx]# /usr/sbin/nginx  -s reload

[root@VM_0_16_centos nginx]# service nginx restart

Redirecting to /bin/systemctl restart  nginx.service

5.再次验证结果,结果可见,最终问题已解决。

 
附录:
1.测试nginx配置是否正确
/usr/local/nginx/sbin/nginx -t

2.重新加载nginx,nginx相关参数

[root@VM_0_16_centos nginx]# which nginx

/usr/sbin/nginx

[root@VM_0_16_centos nginx]# /usr/sbin/nginx -h

nginx version: nginx/1.12.2

Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:

-?,-h         : this help

-v            : show version and exit

-V            : show version and configure options then exit

-t            : test configuration and exit

-T            : test configuration, dump it and exit

-q            : suppress non-error messages during configuration testing

-s signal     : send signal to a master process: stop, quit, reopen, reload

-p prefix     : set prefix path (default: /usr/share/nginx/)

-c filename   : set configuration file (default: /etc/nginx/nginx.conf)

-g directives : set global directives out of configuration file

...



Nginx配置,413 Request Entity Too Large错误解决的更多相关文章

  1. Nginx出现“413 Request Entity Too Large”错误解决方法

    Nginx出现“413 Request Entity Too Large”错误解决方法 2011-03-25 13:49:55|  分类: 默认分类 |  标签:413  request  entit ...

  2. Nginx出现413 Request Entity Too Large错误解决方法

    Nginx出现的413 Request Entity Too Large错误,这个错误一般在上传文件的时候出现,打开nginx主配置文件nginx.conf,找到http{}段,添加 解决方法就是 打 ...

  3. Nginx 出现413 Request Entity Too Large 错误解决方法(上传大小限制)

    | 时间:2013-09-05 20:19:14 | 阅读数:485075 [导读] Nginx出现的413 Request Entity Too Large错误,这个错误一般在上传文件的时候出现,打 ...

  4. Nginx 出现413 Request Entity Too Large得解决方法

    Nginx 出现413 Request Entity Too Large得解决方法 默认情况下使用nginx反向代理上传超过2MB的文件,会报错413 Request Entity Too Large ...

  5. nginx解决超长请求串(413 request Entity too Large错误解决办法)

    <div class="hide-article-box text-center" style="display: block;"> <a c ...

  6. 上传文件报413 Request Entity Too Large错误解决办法

    产生这种原因是因为服务器限制了上传大小 1.nginx服务器的解决办法 修改nginx.conf的值就可以解决了 将以下代码粘贴到nginx.conf内 client_max_body_size 20 ...

  7. Nginx:413 Request Entity Too Large解决

    最近在做给博客添加上传PDF的功能,但是在测试上传文件的过程中遇到了413 Request Entity Too Large错误.不过这个无错误是很好解决的,这个错误的出现是因为上传的文件大小超过了N ...

  8. nginx 出现413 Request Entity Too Large问题的解决方法

    nginx 出现413 Request Entity Too Large问题的解决方法 使用php上传图片(大小1.9M),出现 nginx: 413 Request Entity Too Large ...

  9. wordpress 主题安装 您点击的链接已过期 nginx 出现413 Request Entity Too Large

    1 nginx 出现413 Request Entity Too Large 问题是限制上传大小,解决: 1.打开nginx配置文件 nginx.conf, 路径一般是:/etc/nginx/ngin ...

随机推荐

  1. L3-001 凑零钱 (30 分) dfs加后缀剪枝

    韩梅梅喜欢满宇宙到处逛街.现在她逛到了一家火星店里,发现这家店有个特别的规矩:你可以用任何星球的硬币付钱,但是绝不找零,当然也不能欠债.韩梅梅手边有 1 枚来自各个星球的硬币,需要请你帮她盘算一下,是 ...

  2. Codeforces 1036C Classy Numbers 【DFS】

    <题目链接> 题目大意: 对于那些各个位数上的非0数小于等于3的数,我们称为 classy number ,现在给你一个闭区间 [L,R]  (1≤L≤R≤1018).,问你这个区间内有多 ...

  3. 牛客练习赛37-筱玛的字符串-DP递推

    筱玛的字符串 思路 :dp [ i ] [ j ] [ 3 ] 分别代表到第 i 位时 左括号比右括号多 j ,后面有三个状态 分别表示当前位置 S3的字符 是正在反转的,还是 反转完成的,还是没有反 ...

  4. OSPF补全计划-0 preface

    哇靠,一看日历吓了我一跳,我这一个月都没写任何东西,好吧,事情的确多了点儿,同事离职,我需要处理很多untechnical的东西,弄得我很烦,中间学的一点小东西(关于Linux的)也没往这里记,但是我 ...

  5. Python3基础-代码阅读系列—素数

    生成素数代码展示 质数(prime number)又称素数,有无限个. 质数定义为在大于1的自然数中,除了1和它本身以外不再有其他因数. primenumber = [] upperlimit = 2 ...

  6. LeetCode(509. 斐波那数)

    问题描述: 斐波那契数,通常用 F(n) 表示,形成的序列称为斐波那契数列.该数列由 0 和 1 开始,后面的每一项数字都是前面两项数字的和.也就是: F(0) = 0, F(1) = 1 F(N) ...

  7. 潭州课堂25班:Ph201805201 django 项目 第二十课 数据库分析设计图 (课堂笔记)

    https://www.dbdesigner.net/

  8. Vue发送请求

    可以试试玩ajax请求,个人觉得axios用Promise包装了下,代码美观 axios请求使用方法      https://github.com/axios/axios#using-applica ...

  9. 轻松理解Redux原理及工作流程

    轻松理解Redux原理及工作流程 Redux由Dan Abramov在2015年创建的科技术语.是受2014年Facebook的Flux架构以及函数式编程语言Elm启发.很快,Redux因其简单易学体 ...

  10. BZOJ4083 : [Wf2014]Wire Crossing

    WF2014完结撒花~ 首先求出所有线段之间的交点,并在交点之间连边,得到一个平面图. 这个平面图不一定连通,故首先添加辅助线使其连通. 然后求出所有域,在相邻域之间连一条代价为$1$的边. 对起点和 ...