今天在做Nginx反射代理Tomcat,Nginx如何反向代理Tomcat的.action网页?
如图所示:
后台日志:
2013/03/22 05:15:59 [error] 26165#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.1.3, server: localhost, request: "GET /bank/zsyh.action HTTP/1.1", upstream: "http://127.0.0.1:8080/bank/zsyh.action", host: "192.168.1.222", referrer: "http://192.168.1.222/index.jsp"
上面的配置,我没有写全啊,你去Nginx 官网好好看看吧,很简单的,
详细的配置如下:
location ~ . *\.ation$
{ proxy_cache cache_one;
proxy_cache_valid 200 304 12h;
proxy_cache_valid 301 302 1m;
proxy_cache_valid any 1m;
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_pass http://bak_server;
}
可以用很多种方法:
1.Server
2,upstream
引用来自“葱油拌面”的答案
可以用很多种方法:
1.Server
2,upstream
使用upstream 的话 就是把所有的请求转发给tomcat 服务器
如果你支持想把action 类型的请求转给tomcat的话,建议你采用简单的正则来匹配
在location 中如
location ~ . *\.ation$
( proxy_pass http://tomcat_ip;
)
从的日志来看那,你的tomcat有问题,看下你的应用服务器 即tomcat是不是好的
最简单的办法 直接访问 http://tomcat_ip:tomcat_port
tomcat 都无法解析请求,怎么反向代理啊。网络和逻辑搞清楚
引用来自“葱油拌面”的答案
使用upstream 的话 就是把所有的请求转发给tomcat 服务器
如果你支持想把action 类型的请求转给tomcat的话,建议你采用简单的正则来匹配
在location 中如
location ~ . *\.ation$
( proxy_pass http://tomcat_ip;
)
引用来自“葱油拌面”的答案
上面的配置,我没有写全啊,你去Nginx 官网好好看看吧,很简单的,
详细的配置如下:
location ~ . *\.ation$
{ proxy_cache cache_one;
proxy_cache_valid 200 304 12h;
proxy_cache_valid 301 302 1m;
proxy_cache_valid any 1m;
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_pass http://bak_server;
}
引用来自“ZhouLS”的答案
引用来自“葱油拌面”的答案
使用upstream 的话 就是把所有的请求转发给tomcat 服务器
如果你支持想把action 类型的请求转给tomcat的话,建议你采用简单的正则来匹配
在location 中如
location ~ . *\.ation$
( proxy_pass http://tomcat_ip;
)
看nginx主机能够正常访问tomcat