1. 做一个最简单的反向代理
打开 config\nginx.conf 文件
location / {
root html;
# index index.html index.htm;
proxy_pass http://localhost:8080;
}
对 location 做以上修改,启动 nginx.exe
访问 localhost 即会被反向代理到 localhost:8080
2 尝试负载均衡
upstream test{ #定义upstream名字,下面会引用
server 127.0.0.1:8080; #指定后端服务器地址
server 127.0.0.1:8000; #指定后端服务器地址
}
location / {
root html;
proxy_pass http://test; #引用upstream
}