Welcome! Log In Create A New Profile

Advanced

404 Method not allowed for DELETE as reverse proxy

Posted by ConnorMcLaud 
ConnorMcLaud
404 Method not allowed for DELETE as reverse proxy
May 25, 2018 11:30AM
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 127.0.0.11 valid=60s;
resolver_timeout 5s;
set $upstream_client_data web:5000;
proxy_pass http://$upstream_client_data/client_data;
}


However, everything works fine with

location /client_data {
resolver 127.0.0.11 valid=60s;
resolver_timeout 5s;
proxy_pass http://web:5000/client_data;
}


Full conf:
https://gist.github.com/connormclaud/bc3d65dcb307507c0d8786a168c66b51

What did I do wrong?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279953,279953#msg-279953

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Igor A. Ippolitov
Re: 404 Method not allowed for DELETE as reverse proxy
May 25, 2018 12:00PM
It would be nice to have logs for this problem.
Please, make sure your log format includes upstream address and upstream
status ($upstream_addr and $upstream_status).

On 25.05.2018 12:27, 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 127.0.0.11 valid=60s;
> resolver_timeout 5s;
> set $upstream_client_data web:5000;
> proxy_pass http://$upstream_client_data/client_data;
> }
>
>
> However, everything works fine with
>
> location /client_data {
> resolver 127.0.0.11 valid=60s;
> resolver_timeout 5s;
> proxy_pass http://web:5000/client_data;
> }
>
>
> Full conf:
> https://gist.github.com/connormclaud/bc3d65dcb307507c0d8786a168c66b51
>
> What did I do wrong?
>
> Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279953,279953#msg-279953
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
ConnorMcLaud
Re: 404 Method not allowed for DELETE as reverse proxy
May 25, 2018 12:10PM
I see following bug (closed as invalid):
https://trac.nginx.org/nginx/ticket/1067

Comment from there:
Using variables in proxy_pass implies, that the URI specified is a full one

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279953,279955#msg-279955

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
ConnorMcLaud
Re: 404 Method not allowed for DELETE as reverse proxy
May 25, 2018 12:20PM
I changed my config to the following:

location /client_data {
resolver 127.0.0.11 valid=60s;
resolver_timeout 5s;
set $upstream_client_data web:5000;
proxy_pass http://$upstream_client_data$uri;
}

Now it works!

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279953,279956#msg-279956

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: 404 Method not allowed for DELETE as reverse proxy
May 25, 2018 01:20PM
Hello!

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 127.0.0.11 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,
http://nginx.org/r/proxy_pass.

> }
>
>
> However, everything works fine with
>
> location /client_data {
> resolver 127.0.0.11 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
"http://web:5000/client_data<something>";.

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
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login