C
C
Cyber-Man2016-06-18 15:30:40
Nginx
Cyber-Man, 2016-06-18 15:30:40

How can you get a value from listen?

There is a structure in nginx.conf like this:

server_name site.ru www.site.ru;
                listen 111.10.111.0;
                charset CP1251;
                disable_symlinks if_not_owner from=$root_path;
               include file.conf;

How can I get the value of the listen variable in the file.conf connected using include, that is, IP 111.10.111.0? Is there a variable for this? Thank you.
Addendum:
The following lines are in the file.conf file:
location ~ ^/(wp-admin|wp-login\.php|admin|administrator) {
                        limit_req  zone=wp burst=4 nodelay;
                        proxy_pass http://1.1.1.1:81;
                        proxy_redirect http://1.1.1.1:81/ /;
                        proxy_set_header Host $host;
                        proxy_set_header Host $host;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_set_header X-Forwarded-Proto $scheme;
                        proxy_set_header X-Real-IP $remote_addr;
}

Since there are a lot of domains and they have different IPs in listen, it is necessary that IP corresponding to the domain be substituted in proxy_pass and proxy_redirect ... so I think to do it somehow using a variable, if possible ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nikolayvaganov, 2016-06-18
@nikolayvaganov

set $listen 1.1.1.1;
listen $listen;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question