I
I
Ilyas2018-05-18 20:44:39
Nginx
Ilyas, 2018-05-18 20:44:39

How to set up a redirect to nginx?

Hello, the situation is this:
there are 2 servers behind nat, redirects 80 and 443 go to 1 server, both have nginx installed,
how can I redirect from 1 server to 2 of all *.my.com domains, all sites with such a domain are hosted on 2 there are a lot of such sites on the server and I would not like to manually add the config for each on 1 server
how to get out of this situation?
diagram for clarity
5aff10c81915b678661674.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mysterion, 2018-05-18
@id2669099

Here only if proxying.

server {
    listen 80;
    server_name *.my.com;
    location / {
        proxy_pass http://2_server_ip;
    }
}

server {
    listen 443 ssl;
    server_name *.my.com;
    location / {
        proxy_pass https://2_server_ip;
    }
}

A
Alex McArrow, 2018-05-18
@AlexMcArrow

As Mysterion wrote + if the main domain is on the first server, then subdomains can be isolated with a regular expression

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question