您的位置:首页 > 运维架构 > 反向代理

关于nginx+tomcat搭建反向代理时加载静态资源找不到的问题

2017-12-08 15:24 781 查看
1 、在配置nginx的反向代理时在localtion下需要

upstream tomcat_nginx{

server 127.0.0.1:8888;

server 127.0.0.1:8889;

}

location / {

proxy_pass http://tomcat_nginx;
proxy_set_header Host $host;//解决加载静态资源找不到的问题

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_redirect default ;

root html;

index index.html index.htm;

proxy_connect_timeout 1;//解决多个tomcat一个崩溃后加载慢的问题

proxy_read_timeout 1;//解决多个tomcat一个崩溃后加载慢的问题

proxy_send_timeout 1; //解决多个tomcat一个崩溃后加载慢的问题

}

2.当nginx代理端口不是80的时候需要修改tomcat的server.xml文件将connector的节点中增加一个proxyPort="nginx的端口号" nginx代理端口的位置
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: