在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/;
}
}