-
新建项目
server { listen 9001; server_name test.com; location / { root /home/www/dist; index index.html; try_files $uri $uri/ /index.html; } }
-
配置反向代理
server { listen 9000; server_name test.com; location / { proxy_pass http://localhost:9001; } }
-
配置负载均衡
upstream test_upstream { server http://localhost:9001; server http://localhost:9002; server http://localhost:9003; } server { listen 9000; server_name test.com; location / { proxy_pass test_upstream; } }
-
更新 nginx 配置信息
nginx -s reload
浏览器打开 查看