Forum: NGINX Proper way to get uri of backend server

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B070efe6b9226cbaf5f2ec06d2d3451c?d=identicon&s=25 Chavelle Vincent (vchav)
on 2009-03-09 14:59
(Received via mailing list)
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
This topic is locked and can not be replied to.