nginx config http block ip address incoming request listening ip

126 views Asked by At

I am looking for help to detect the IP in nginx config http block ( no server block ) I have two IP on same machine and pointing to common nginx. I want to know and find the IP on which incoming request was made to ( not from ),I mean between two IPs which IP received the request.

1

There are 1 answers

0
Ivan Shatsky On

You can check the value of $server_addr nginx variable, but take into account that it would require an extra system call for every incoming request and produce some extra overhead. It can be better to define two server blocks with two different listen directives, for example listen <IP1>:80; and listen <IP2>:80; if you want different behaviour depending on that address.