Welcome! Log In Create A New Profile

Advanced

Re: proxy_pass with variable removes uri

Maxim Dounin
March 05, 2014 07:34AM
Hello!

On Wed, Mar 05, 2014 at 07:23:23AM -0500, luckyswede wrote:

> Hi,
> I've had troubles with url-decoding using this kind configuration, e.g. get
> variables with values containing spaces have been decoded before proxied
> which is resulting in an error.
> For example I've tried:
> location ~ ^/api/(.*) {
> proxy_pass http://api.$host/$1$is_args$args;
> }
> but that gives an error if the uri is urlencoded.
>
> Any ideas?

When using variables you are responsible for proper encoding of
URIs used.

If you really want to use proxy_pass with variables, try this
instead:

location /api/ {
rewrite ^/api(/.*) $1 break;
proxy_pass http://api.$host;
}

It relies on the fact that if there is no URI at all, original
request uri will be used.

Though I would recommend using hardcoded name instead. Note that
using proxy_pass with variables implies various other side
effects, notably use of resolver for dynamic name resolution, and
generally less effective than using names in a configuration.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

proxy_pass with variable removes uri

luckyswede March 05, 2014 05:47AM

Re: proxy_pass with variable removes uri

Maxim Dounin March 05, 2014 06:24AM

Re: proxy_pass with variable removes uri

luckyswede March 05, 2014 07:23AM

Re: proxy_pass with variable removes uri

Maxim Dounin March 05, 2014 07:34AM

Re: proxy_pass with variable removes uri

luckyswede March 05, 2014 07:46AM

Re: proxy_pass with variable removes uri

Maxim Dounin March 05, 2014 08:44AM

Re: proxy_pass with variable removes uri

Francis Daly March 05, 2014 07:44AM

Re: proxy_pass with variable removes uri

Valentin V. Bartenev March 05, 2014 06:24AM

Re: proxy_pass with variable removes uri

luckyswede March 05, 2014 06:29AM

Re: proxy_pass with variable removes uri

luckyswede March 05, 2014 07:26AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 261
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready