angelafanfan0329
rogue2yjg
2017-07-15 07:50

POST文件上传请求,Nginx报405错误

  • nginx
  • 405
  • 文件上传

以下是nginx日志:
175.171.184.77 - - [15/Jul/2017:14:19:35 +0800] "POST /newsedit/upload HTTP/1.1" 405 0 "http://www.xxx.com/newsedit/create" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3128.0 Safari/537.36"

以下是分析过程:
1、代码在本地win环境(未使用nginx)运行没有异常,上传功能正常;
2、部署到linux服务器上之后,使用了nginx,上传功能报405错误;
3、在同一个linux服务器上部署的另一套应用也有文件上传功能,可以正常使用;
4、故分析是nginx的配置问题;

以下是同一个linux服务器上两套应用的nginx配置:

1、上传功能异常:

 server {
        listen       80;
        server_name  xxx.com xxx.net yyy.com yyy.net;

        access_log  logs/portal.access.log;

        location / {
            root   html;
            index  index.html index.htm;
          proxy_pass   http://www.xxx.com:8300;
        }
      location /portal {
            root   html;
            index  index.html index.htm;
          proxy_pass   http://www.xxx.com:8300;
        }
        location /privacy.html {
            root html;
            proxy_pass http://asset.xxx.com:9001/privacy.html;  
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

2、上传功能正常:

 server {
        listen       80;
        server_name  m.xxx.com m.xxx.net m.yyy.com m.yyy.net;

        access_log  logs/maintenance.access.log;

       location / {
           root   html;
           index  index.html index.htm;
        proxy_pass   http://m.xxx.com:9300;
        proxy_redirect default;
       }

       location ^~ /eplus/ws/server {
           proxy_pass http://m.xxx.com:9300;

           proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐