下面的内容主要为实战而非原理,说错的地方,请指正。
通过nginx进行反向代理:通过8084代理8081和8082端口
具体配置
修改nginx.conf文件,在http下添加
#
upstream backend{
server localhost:8081;
server localhost:8082;
}
然后在 location中添加
proxy_pass http://backend;
这里的site 跟 upstream后面的名字对应。
不懂的可以看截图
通过listen的节点 http://localhost:8084轮询访问到http://localhost:8081和http://localhost:8082,但不是一定顺序执行,看具体的业务执行时间。