Welcome! Log In Create A New Profile

Advanced

Re: proxy_redirect and variables

Maxim Dounin
March 29, 2010 01:00PM
Hello!

On Mon, Mar 29, 2010 at 05:30:19PM +0200, Tobia Conforto wrote:

> Does anybody know anything about this?

Yes.

> > Does anybody know why proxy_redirect won't interpolate variables in its first argument?

Because it doesn't. If you think you are brave enough to change
it - submit patches.

> > I'm trying to setup a reverse proxy to a backend that uses
> > name-based virtual hosts, so I need to change both the
> > incoming Host header and the outgoing Location headers:
> >
> > server {
> > server_name public.hostname.com;
> >
> > set $proxy_to private.hostname.com
> >
> > location / {
> > proxy_pass http://backend;
> > proxy_redirect http://$proxy_to/ http://$host/;
> > proxy_set_header Host $proxy_to;
> > }
> > }
> >
> > This doesn't work, unless I expand $proxy_to in proxy_redirect
> > by hand.
> >
> > Am I supposed to write it in another way?

For the above config you shouldn't use variables at all, use
literal strings instead (and/or some config generator if you want
to save typing). Variables are evaluated at run time and should
be used only when they have to be different for different
requests.

Maxim Dounin

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

proxy_redirect and variables

Tobia Conforto March 23, 2010 10:58AM

Re: proxy_redirect and variables

Tobia Conforto March 29, 2010 11:38AM

Re: proxy_redirect and variables

Maxim Dounin March 29, 2010 01:00PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 178
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