- 打开nginx下面的conf文件夹下面的nginx.conf文件,如图
- nginx.conf文件配置,并保存,如图:
代码:
#定义集群
upstream demo{
server localhost:1111;
server localhost:2222;
}
- 1
- 2
- 3
- 4
- 5
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# root html;
#index http://localhost:8080/;
proxy_pass http://demo;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 启动nginx,如图
- 打开浏览器,输入地址,如图:
http://localhost:8080/接口地址
nginx博客: