nginx负载均衡

1、windows下免安装nginx,直接运行即可,双击nginx; exe;
2、修改D:\nginx-1.12.2\conf\nginx.conf;
upstream springtest{
server localhost:2000;
server localhost:2003 down;
}
server {
listen 8888;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://springtest;
}
3、访问地址:http://localhost:8888/demo/hi;
4、分别启动2000端口和2003端口应用;
5、不停的刷新可以看到端口在变化;
springboot代码清单:
@RestController
public class HiController {
@Value("${server.port}")
String port;
@GetMapping("/hi")
public String home() {
return "hi ,i am from port:"+port;
}
}
【nginx负载均衡】以上简单描述记录;

    推荐阅读