404 Method not allowed for DELETE as reverse proxy

Maxim Dounin mdounin at mdounin.ru
Fri May 25 11:09:20 UTC 2018


On Fri, May 25, 2018 at 05:27:24AM -0400, ConnorMcLaud wrote:

> Hi, I use nginx as reverse proxy to my Flask web server and have following
> problem:
> after I changed proxy pass to variable DELETE requests started to return 405
> Method not allowed (while POST works fine)
>         location /client_data {
>             resolver valid=60s;
>             resolver_timeout 5s;
>             set $upstream_client_data web:5000;
>             proxy_pass http://$upstream_client_data/client_data;

With this config, all requests to "/client_data<anything>" will be 
routed to "http://web:5000/client_data" URI.

When using variables in the proxy_pass, you are expected to 
specify _full_ URI.  Using an URI component to replace a part of 
the URI matched by location prefix, won't work.  See details in 
the proxy_pass directive description, 

>         }
> However, everything works fine with
>         location /client_data {
>             resolver valid=60s;
>             resolver_timeout 5s;
>             proxy_pass http://web:5000/client_data;

And this config is quite different.  With this config, requests to 
"/client_data<something>" will be routed to 

In both cases, "/client_data" part in the proxy_pass directive 
looks unneeded.  That is, use

    proxy_pass http://web:5000;

instead.  And with variables equivalent construction would be

    set $upstream_client_data web:5000;
    proxy_pass http://$upstream_client_data;

Note no URI compontent in proxy_pass in both cases.

Maxim Dounin

More information about the nginx mailing list