P
P
Pista2019-11-08 11:54:08
Nginx
Pista, 2019-11-08 11:54:08

How to proxy nginx to a domain name?

The task is to use VPS 1 as an IP address for domains, and store sites on VPS 2 , i.e. I need only an IP address from VPS 1 in order to create an A record for domains.
I used proxy_pass
On VPS 1, I created a cofing for the domain
location / {
proxy_pass testpage.ru;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
The catch is that the request goes to the IP address of the domain, on this IP address I have several dozen domains, I need to refer to a specific domain, how to do this?
For example, I access testpage.ru and I need to open the contents of testpage.ru which is on VPS2, but now I see another site that is hosted on the same IP

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2019-11-08
@Pista

To VPS2create configs with the appropriate server_nameand from VPS1 in the header Host, transfer the domain name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question