nginx错误集

1、nginx反向代理400错误

现象:

 使用Nginx的反向代理访问tomcat时400错误。

upstream配置:

  upstream tomcat_server {
    server 192.168.2.80:8080 weight=1;
    server 192.168.2.90:8080 weight=3;
    }
    ...........
    location / {
            root   html;
            index  index.html index.htm;
            proxy_pass http://tomcat_server;
        }

原因:

nginx中upstream后面的名称不能使用下滑线,Nginx不能识别。

解决办法:

将tomcat_server改成tomcatserver后问题解决。

 upstream tomcatserver {                                 //名字里面不能有下划线
    server 192.168.2.80:8080 weight=1;
    server 192.168.2.90:8080 weight=3;
    }
  location / {
            root   html;
            index  index.html index.htm;
            proxy_pass http://tomcatserver;     //代理跟着改
        }

 2、favicon.ico" failed (2: No such file or directory)错误

解决办法:

关闭favicon.ico的日志

编辑nginx.conf,添加如下命令

 location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

 3、413 Request Entity Too Large

现象:

在使用Nginx服务过程中,经常会遇到上传文件超过限制的情况,会报"413 Request Entity Too Large"的错误。

解决办法:

编辑nginx.conf文件,如果我们要上传的文件大小为10M以下,就在http{ }中设置

client_max_body_size 10m;

原文地址:https://www.cnblogs.com/John-2011/p/14817780.html