nginx基于IP的虚拟主机
知識點:
server的語法:
upstream語法:
upstream中192.168.100.1不是ip只是個標識,只要和下面的proxy_pass 對應(yīng)即可。
基于IP的虛擬主機:
listen和server_name中多加上端口也沒問題
listen可以監(jiān)聽在虛擬ip上面
?
代碼:
upstream 192.168.100.1{
server 10.10.30.100:8081 backup;
server 10.10.30.101:8081?max_fails=3 ?fail_timeout=5s;
server 10.10.30.102:8081?max_fails=3 ?fail_timeout=5s; ? ? #健康狀態(tài)檢測
}
server {
listen 192.168.100.1:8020;
server_name 192.168.100.1:8020;
location / {
index index.jsp;
proxy_pass http://192.168.100.1;
proxy_cookie_path /192.168.100.1/ /;
proxy_set_header Host $http_host;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /download/ {
root html;
}
}
?
#存在iptables的情況下記得開啟iptables的端口
?
轉(zhuǎn)載于:https://www.cnblogs.com/fanxuanhui-linux/p/6036211.html
總結(jié)
以上是生活随笔為你收集整理的nginx基于IP的虚拟主机的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 骂人的个性签名心情不爽的
- 下一篇: 来谈谈你心中的杨洋。?