is there a way to force a specific ip address to always go to the same server in upstream?

Joshua Zhu zhuzhaoyuan at gmail.com
Tue Sep 15 08:52:24 MSD 2009


Something like this?

http {
    upstream backend {
        server 127.0.0.1:8001;
        server 127.0.0.1:8002;
        server 127.0.0.1:8003;
    }

    server {
        listen 8080;
	server_name localhost;
	
        location / {
            if ($remote_addr = 127.0.0.1 ) {
                proxy_pass http://127.0.0.1:8003;
                break;
            }

            proxy_pass http://backend;
        }
    }
}


On Tue, Sep 15, 2009 at 11:55 AM, Ilan Berkner <iberkner at gmail.com> wrote:
> Thanks, that's not what I mean.
>
> For testing purposes, we'd like to have our work computers go to a
> particular upstream server at all times.  I think that the ip_hash directive
> for the most part accomplishes that, but doesn't force one server over the
> other.  Whichever one you end up with is the one you get... am I wrong?
>
> thanks
>
> On Mon, Sep 14, 2009 at 10:00 PM, Joshua Zhu <zhuzhaoyuan at gmail.com> wrote:
>>
>> Hi,
>>
>> Yes.
>> http://wiki.nginx.org/NginxHttpUpstreamModule#ip_hash
>>
>> On Tue, Sep 15, 2009 at 9:42 AM, Ilan Berkner <iberkner at gmail.com> wrote:
>> >
>> >
>>
>> Regards,
>>
>> --
>> Joshua Zhu
>> http://www.zhuzhaoyuan.com
>>
>
>

Regards,

-- 
Joshua Zhu
http://www.zhuzhaoyuan.com





More information about the nginx mailing list