您的位置:首页 > 运维架构 > Tomcat

Nginx与tomcat集成

2014-04-15 11:36 323 查看

第一步:实现tomcat和nginx可以顺利启动。

请查看官方文档

第二步:配置nginx的配置文件nginx/nginx.conf

找到location / { … } 元素,在花括号里面加入
proxy_pass http://127.0.0.1:8080;[/code] 注意 
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管理页,说明配置成功。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: