1、nginx下载配置
https://www.cnblogs.com/wangwust/p/6420503.html 安装下载地址
nginx配置文件nginx.conf
#keepalive_timeout 0;
keepalive_timeout 65;
#服务器集群
upstream tomcats{
server 192.168.1.112:8070 weight=1;
server 192.168.1.112:8071 weight=2;#可以在这里加权重
}
#gzip on;
server {
listen 80;
server_name 192.168.1.112;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
proxy_pass http://tomcats/;
}
2、springboot的controller模块的代码
3、springboot的配置文件配置端口号
4、使用Postman试着去跑后端接口
http://localhost/hi访问该接口,每次结果可能一样,也可能是一样的,实现了访问同一接口,会到不同的后端接口去获取资料,减轻了服务器的压力,实现了系统的负载均衡。