Welcome! Log In Create A New Profile

Advanced

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

September 15, 2009 01:12AM
On Tue, Sep 15, 2009 at 12:52:24PM +0800, Joshua Zhu wrote:

> 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;
> }
> }
> }

This is better:

http {
map $remote_addr $back {
default backend;
127.0.0.1 127.0.0.1:8003;
}

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 / {
proxy_pass http://$back$request_uri;
}
}
}


> On Tue, Sep 15, 2009 at 11:55 AM, Ilan Berkner <iberkner@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@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> Yes.
> >> http://wiki.nginx.org/NginxHttpUpstreamModule#ip_hash
> >>
> >> On Tue, Sep 15, 2009 at 9:42 AM, Ilan Berkner <iberkner@gmail.com> wrote:


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

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

iberkner September 14, 2009 09:52PM

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

Joshua Zhu September 14, 2009 10:08PM

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

iberkner September 15, 2009 12:06AM

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

Joshua Zhu September 15, 2009 01:00AM

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

Igor Sysoev September 15, 2009 01:12AM

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

Momchil Ivanov September 15, 2009 06:42PM

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

Maxim Dounin September 15, 2009 07:00PM

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

Momchil Ivanov September 16, 2009 05:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 110
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready