Answer the question
In order to leave comments, you need to log in
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
Answer the question
In order to leave comments, you need to log in
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;
}
}
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 questionAsk a Question
731 491 924 answers to any question