Nginx发布方法不起作用 [英] nginx post method does not work

查看:185
本文介绍了Nginx发布方法不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

nginx在使用Http POST方法下载Excel文件时遇到问题.实际上,我得到的状态码为:405不允许.

I have a problem with nginx to download an excel file using the Http POST method. In fact I am getting a Status Code: 405 Not Allowed.

这是我的配置

upstream backend{
    server localhost:9090;
    server localhost:9091;
    server localhost:9092;
    server localhost:9093;
}

server {
    listen       8887;
    server_name  localhost;

    location / {
        proxy_pass  http://backend;
        proxy_next_upstream error timeout http_404; 
        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;
    }
}

我该如何解决这个问题.

how can I solve this problem.

谢谢.

推荐答案

对于尝试访问静态资产的POST请求,Nginx使用HTTP 405进行响应.

Nginx responds with an HTTP 405 for POST requests that try to access a static asset.

几年前的Nginx版本文档:

From the Nginx release docs from a few years back:

*) Feature: now Nginx returns the 405 status code for POST method requesting a static file only if the file exists.

*) Feature: now Nginx returns the 405 status code for POST method requesting a static file only if the file exists.

一种解决方法是添加以下行,该行会更改响应代码并将您发送到请求的URI:

A way to go around it would be to add this line, which changes the response code and sends you to the requested URI:

error_page 405 =200 $uri;

您可以在此处找到其他解决方案:

You can find other solutions here:

http://invalidlogic. com/2011/04/12/serving-static-content-via-post-from-nginx/

我希望这会有所帮助.

这篇关于Nginx发布方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆