问题情景:
当我访问hg.test.com的时候,Nginx 需将二级域名需转发到Tomcat的 http://localhost:10010/test/index/ 意思就是要将不同的二级域名转发该tomcat的不同url地址。且不影响JSP页面中的路径。
现在的问题是,如果使用代理proxy_pass http://localhost:10010/test/index; 转发,那么程序中所有使用的相对路径前面都会加上test/index.
这种情况该怎么写? 哪位兄弟处理过这种情况,写个示例,不胜感激!
server {
listen 80;
server_name hg.test.com;
location ~ \.(htm|html|gif|jpg|jpeg|png|ico|rar|css|js|zip|txt|flv|swf|doc|ppt|xls|pdf)$ {
root /var/data/test/webapp;
access_log off;
expires 24h;
}
location / {
proxy_pass http://localhost:10010/;
include proxy.conf;
}
}
nginx 做不了这个的,访问 nginx 之前的 url 后缀要跟 nginx 转到 tomcat 后的 url 后缀一致
例如 http://www.oschina.net/question -> http://localhost:8080/question