###第一步:实现tomcat和nginx可以顺利启动。### 请查看官方文档
###第二步:配置nginx的配置文件nginx/nginx.conf ### 找到location / { ... } 元素,在花括号里面加入proxy_pass http://127.0.0.1:8080;
注意 127.0.0.1
不要写成localhost
,否则可能会出现循环请求,而刷不出页面的情况;
###附加步骤:开启nginx负载均衡### 在server标签前面配置
<!-- lang: shell -->
upstream backend {
server 127.0.0.1:8080 weight=6 max_fails=2 fail_timeout=5;
server 127.0.0.1:8081 weight=4 max_fails=2 fail_timeout=5;
}
在server标签里面配置
location / {
#root html;
#index index.html index.htm;
proxy_pass http://backend;
}
尝试访问 http://localhost/
,出现tomcat管理页,说明配置成功。