I
I
Iceforest2021-10-16 13:00:30
Nginx
Iceforest, 2021-10-16 13:00:30

Why does NGINX incorrectly determine the ip address of the server from the dns name?

There are two servers, nginx is installed on one server, plus the site les.lesok.ru is running on port 80. I want to redirect the request to another server to the second site dom.domik.ru, but for some reason, when requesting the second site, nginx determines the ip of the current server from it and, accordingly, gives incorrect data. The
config is like this

server
{
        listen 80;
        server_name dom.domik.ru;
location /
        {
                return 301 https://dom.domik.ru;
        }
}
server
{
        listen 443 ssl;
        ssl_certificate     /usr/local/nginx/conf/cert.pem;
        ssl_certificate_key /usr/local/nginx/conf/cert.key;
        server_name dom.domik.ru;
        location /
                {
                        proxy_pass http://10.*.*.50;
                        proxy_set_header Host 10.*.*.50;
                }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Karabanov, 2021-10-16
@Iceforest

The proxied server needs to send the Host header if IP is used as the proxy address and the target site is not default on the proxied serverproxy_set_header Host "example.com";

D
Dimonchik, 2021-10-16
@dimonchik2013

and what. in server name it is already possible to write the protocol/scheme?
nginx.org/ru/docs/http/server_names.html
or is it some kind of regular expression? ))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question