Proper way to get uri of backend server

Vincent Chavelle vincent.chavelle at gmail.com
Mon Mar 9 16:46:28 MSK 2009


Hi everybody,

I want return a page with simply the uri of backend server. For
example, I have two servers (one.mydomain.com, two.mydomain.com) and
when a client ask to /geturi/?TEST=hello, I want to hash 'hello' for
retrieving a server hostname.

This is my solution :

# on loadbalancer
upstream backend_ap {
        server one.mydomain.com;
        server two.mydomain.com;
        hash   $arg_TEST;
    }

location /geturi {
       default_type  text/html;
       proxy_pass http://backend_ap;
}

# on backend server
location / {
       root html;
       index /index.html;

       allow   X.X.0.0/16;
       deny    all;
}

# cat /usr/local/nginx/html/index.html
one.mydomain.com

Do you have a faster way ?

Thanks in advance

Vincent Chavelle





More information about the nginx mailing list