N
N
NOONE2017-10-05 20:16:33
Nginx
NOONE, 2017-10-05 20:16:33

NGINX proxying all requests for all domains to another NGINX, how?

How can and is it possible to implement such a scheme, there is an old server on it with many domains, we want to move to a new one, we need to proxy all requests for all domains to the new server until the domain zone switches to the new server, how can this be implemented? There are virtual hosts that are easy to configure, there are complex ones, is it possible to do this somehow without registering in each proxy_pass?
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Zubkov, 2017-10-05
@zubkov_work

On the old server, delete all virtual hosts. Create one in which to specify server_name _ ; And the required proxy_pass . That's all. Any domain name will be forwarded to proxy_pass.

V
Vladimir Mukovoz, 2017-10-08
@castomi

well, it's that simple)

location / {
    proxy_pass       http://111.111.111.111;
    proxy_set_header Host      $host;
    proxy_set_header X-Real-IP $remote_addr;
}

111.111.111.111 - ip of the new server. You just need to take into account the moment so that the old server reads exactly the sites from the new one, you need to either make sure it has updated DNS or specify them manually or resort to using this directive.
https://nginx.ru/ru/docs/http/ngx_http_core_module...
PS And you can also forward all traffic on ports 80 and 443 through iptables))) It will be even cooler in my opinion))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question