通过一台nginx服务器代理多个域名进行跳转,原理很简单,重点在玩法!适用于公司处理域名紧急备案问题。
域名:
www.hx123.com
www.hx456.com
nginx服务器:
ginx.conf
实现:
www.hx123.com 域名连接到nginx服务器自动代理到 http://192.168.95.180:8080
www.hx:456.com域名连接到nginx服务器自动代理到 http://192.168.95.181:8181
server1:
server { listen 80; server_name www.hx123.com; location / { proxy_set_header Host hx123.com; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://192.168.95.180:8080; } }
server2:
server {
listen 80;
server_name www.hx:456.com;
location / {
proxy_set_header Host hx456.com;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://192.168.95.181:8181;
}
}