Nginx1.18.0版本负载均衡配置详细

打开nginx下面的conf文件夹下面的nginx.conf文件,如图

nginx.conf文件配置,并保存,如图:
代码:
#定义集群
upstream backend_server{
server localhost:9001;
server localhost:9002;
}

listen 9000;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
# root html;
#index http://localhost:9000/;
proxy_pass http://backend_server;
}

  

启动nginx

打开浏览器,输入地址,如图:
http://localhost:9000/接口地址

 

原文地址:https://www.cnblogs.com/Gxiaopan/p/14658004.html