nginx的反向代理的几种形式及upstream负载均衡的用法
时间:2023-6-29 10:15 作者:Anglei 分类: WEB应用
基于IP地址及端口的反向代理方式:
server {
listen 81;
server_name localhost;
location / {
proxy_pass http://192.168.0.153:9091;
proxy_redirect default;
}
location = /50x.html {
root html;
}
}
基于域名的反向代理方式:
server {
listen 82;
server_name localhost;
location / {
proxy_pass http://git.itplh.com;
proxy_redirect default;
}
location = /50x.html {
root html;
}
}
基于域名代理 + upstream负载均衡
upstream gitlocal{
server 192.168.0.153:9091;
server 192.168.0.154:9091;
server 192.168.0.155:9091;
}
#上述代码位于http{}内
server {
listen 80;
server_name gitlocal.com;
location / {
proxy_pass http://gitlocal;
proxy_redirect default;
}
location = /50x.html {
root html;
}
}
本文完结,相关标签: nginx
推荐阅读:
![]() 路过(0) |
![]() 雷人(0) |
![]() 握手(0) |
![]() 鲜花(0) |
![]() 鸡蛋(0) |