目录
1.nginx反向代理-负载均衡
1)搭建web项目
首先通过SpringBoot+Freemarker
快速搭建一个WEB
项目:springboot-web-nginx然后在该项目中,创建一个IndexNginxController.java
文件
@Controller
public class IndexNginxController {
@Value("${server.port}")
private String port;@RequestMapping("/")
public ModelAndView index(){
ModelAndView model = new ModelAndView();
model.addObject("port", port);
model.setViewName("index");
return model;
}
}
在该Controller
类中,存在一个成员变量:port
,它的值即是从application.properties
配置文件中获取server.port
值。当出现访问/
资源的请求时,跳转前端index
页面,并将该值携带返回
前端的index.ftl
文件代码
<html>
<head>
<title>Nginx演示页面</title>
<link href="nginx_style.css&#