Upsteam + proxy_redirect?

Hi,
here is part of nginx.conf ; in some condition mysite1.com redirect
users
to some of its url so i need to use proxy_redirect in my locations;

now i want to start using upstream to add load balancing to my site;

the location v1 is working fine with my main site but when i want to
change its setting to something like location v2 it does not work and
redirect browser to mysite1.com and users can see the real site behind
the mynginxserver.com

can i use proxy_redirect when i use upstream ??

users type myngixxserver.com in their browser;
images stores on mysite2.com;
i will add more server to my upstream when the problem solves;
sorry for my bad english
mystic and mysite2 ip addresses are invalid

if more info is needed plaza tel me
thank you in advance;


upstream mysites {
server www.mysite1.com;
}

upstream myimages {
server image.mysite1.com;
}
location /v1 {
proxy_pass http://www.mysite1.com;
proxy_redirect http://www.mysite1.com/v1
http://www.mynginxserver.com/v1
}

location /v2 {
proxy_pass http://mysites/v2;
proxy_redirect http://www.mysite1.com
http://www.mynginxserver.com/v2;
}

location /images {
proxy_pass http://www.mysite2.com/images;
}

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

Hello!

On Tue, Jun 14, 2011 at 03:24:52AM -0400, torajx wrote:

if any more info needed plz tell me;
why v1 works but v2 does not ???

Try looking what your backend actually returns in ‘Location’
header.

Maxim D.

if any more info needed plz tell me;
why v1 works but v2 does not ???

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,206003,206652#msg-206652

thank you, i will try; but what is different between v1 and v2 ;
i just use upstream in v2 and server in upstream is the same as v1
server;

thank you

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,206003,206675#msg-206675

Hello!

On Tue, Jun 14, 2011 at 06:03:52AM -0400, torajx wrote:

thank you, i will try; but what is different between v1 and v2 ;
i just use upstream in v2 and server in upstream is the same as v1
server;

The difference is upstream name: in v1 you use your domain (the
same as in proxy_redirect), while in v2 you use upstream{} block
name. Upstream name is used in Host header in request to upstream
by default[1], and this may (and likely will) cause your backend
to return different redirects.

BTW, proxy_redirect default will use upstream name as well, and
this should handle such situations transparently. See [2] for
details.

[1] http://wiki.nginx.org/HttpProxyModule#proxy_set_header
[2] http://wiki.nginx.org/HttpProxyModule#proxy_redirect

Maxim D.

thank you;
I checked proxy_redirect default; in v2 but it did not worked;
but i try to check everything again;

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,206003,206746#msg-206746

Hiiiiiiiiiiiiiiii,

the problem solved with :
proxy_set_header Host www.mysite1.com;

thank you very much;

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,206003,207019#msg-207019

hi again
only one question left;
i want to add more server to my upstream;
i tried to use this :
proxy_set_header Host $upstream_addr;

but $upstream_addr contains port of upstream server too;
i did not find any thing yet to remove port from $upstream_addr;
how can i do it ?

thanks again

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,206003,207030#msg-207030

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs