Answer the question
In order to leave comments, you need to log in
How to redirect a domain in nginx to another local IP address?
Available:
At the input of Mikrotik (external IP 99.99.99.99; local IP 192.168.0.1)
Web server NGINX (local IP 192.168.0.2)
Mail server iRedmail (local IP 192.168.0.3)
Settings:
On Mikrotik, external port 80 is forwarded to local IP 192.168.0.2:80 (NGINX)
On NGINX:
server {
listen 80;
server_name mail.babruisk.ru www.mail.babruisk.ru;
location / {
proxy_pass http://192.168.0.3:80/;
proxy_set_header Host mail.babruisk.ru;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
server_name mail.babruisk.ru www.mail.babruisk.ru;
location / {
proxy_pass http://192.168.0.3:80;
proxy_redirect default;
proxy_redirect http://192.168.0.3:80/ http://mail.babruisk.ru/;
}
}
server {
listen 80;
listen 443;
server_name mail.babruisk.ru www.mail.babruisk.ru;
location / {
proxy_pass https://192.168.0.3:443;
proxy_redirect default;
proxy_redirect https://192.168.0.3:443/ https://mail.babruisk.ru/;
}
}
server {
listen 443;
server_name mail.babruisk.ru www.mail.babruisk.ru;
access_log /var/log/nginx/ssl-access.log;
ssl on;
ssl_certificate /var/ssl/iRedMail.crt;
ssl_certificate_key /var/ssl/iRedMail.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location / {
proxy_pass https://192.168.0.3/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass_header Set-Cookie;
}
}
Answer the question
In order to leave comments, you need to log in
Mihai, you smiled at me))) You won’t believe it, and there is no mail.babruisk.ru))) I won’t paint my network with real IP here)))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question