0

I need nginx to redirect requests without proxying. I have this nginx.config file:

http {
        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        upstream web_rack {
                server ip_address_1;
                server ip_address_2;
                server ip_address_3;
                server ip_address_4;
        }

        server{
                listen 80;
                location / {
                        proxy_pass http://web_rack;
                        rewrite ^ http://<variable>$request_uri permanent;
                }
        }
}

How can I get server's IP-address who took the redirected request from nginx. I guess there exist some "variable" which stores this IP address but I don't know how to get it.

Vova2204
  • 1
  • 2

1 Answers1

0

Thanks everyone for help)

I've solved my problem with that config:

http{
            include /etc/nginx/mime.types;
            default_type application/octet-stream;

            upstream web_rack {

                    server localhost:8080;
                    server localhost:8081;
            }

            server{
                    listen 80;
                    location / {
                            proxy_pass http://web_rack;
                    }
            }

            server{
                    listen localhost:8080;
                    location / {
                            return 302 https://ip_address_1$request_uri;
                    }
            }

            server{
                    listen localhost:8081;
                    location / {
                            return 302 https://ip_address_2$request_uri;
                    }
            }
}
Vova2204
  • 1
  • 2