环境
系统:Windows7
Nginx版本:1.26.2
Nginx负载均衡实现
- 实现逻辑
Nginx1:访问入口
Nginx2、Nginx3、Nginx4:组成负载集群
- 配置C:\Windows\System32\drivers\etc\hosts文件
新增IP域名映射
127.0.0.1 backend1.com
127.0.0.1 backend2.com
- Nginx1配置
http {
upstream backend {
server backend1.com:8081;
server backend2.com:8082;
server backend3.com:8000 backup;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://backend;
}
}
}
- Nginx2配置
http {
server {
listen 8081;
server_name backend1.com;
}
}
- Nginx3配置
http {
server {
listen 8082;
server_name backend2.com;
}
}
- Nginx4配置
http {
server {
listen 8000;
server_name backend3.com;
}
}
标签:http,入门,name,实践,server,Nginx,com,listen
From: https://www.cnblogs.com/luoxiaolei/p/18410093