T
T
tefoxis2020-04-22 12:01:26
Nginx
tefoxis, 2020-04-22 12:01:26

nginx. Why does the $server_addr directive only return the server's local ip?

Hello.

There is an nginx server on the network.
Inside his ip, let
's say 192.168.100.10 Outside NAT, his ip 52.200.200.10

There is a $server_addr directive in Nginx, which, judging by the description:

$server_addr, эта переменная равна адресу сервера, на который пришёл запрос. Как правило, для получения значения этой переменной делается один системный вызов.


I need that, depending on whether they came from outside or from inside, $server_addr equals either the internal ip or the external one.
But now I would not go in, judging by the logs, $server_addr only stores the internal Ip. Why can this be so? Wrong config? Is it even possible?

My config (for example):
server {
     listen 80;
     server_name example.com;
     return 301 https://$host$request_uri;
}
server {
     listen 443 ssl;
     server_name example.com;
......................................
}


Thanks in advance for your replies

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2020-04-22
@ky0

Since you have an external address - not on the server, then it will never be used. What problem are you trying to solve with this variable?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question