在http{} 下面加入
upstream webservers{
server 192.168.2.4:8087 weight=10;
server 192.168.2.154:8080 weight=10;
}
server 中配置
server {
listen 8000;
#listen localhost:8080;
#server_name localhost:8080;
location / {
root spa;
index index.html index.htm;
}
location ^~ /apis/ {
proxy_pass http://webservers/api/;
}
}
本文介绍了如何在Nginx中设置上游服务器(upstream),实现负载均衡,将请求分发到多个服务器。配置包括定义服务器权重以及在location块中使用proxy_pass将请求代理到指定的服务器群组。
1086

被折叠的 条评论
为什么被折叠?



