如何更正位于 /myapp 的 Tomcat(Wicket 中)位于 / 后面的 Apache 代理,将错误的重定向发送到 /myapp/xxx 而不是 /xxx?
我已将 Wicket 应用程序部署在 Tomcat 中的 /myapp,并且已将其放在 Apache Web 服务器后面,使用
ProxyPass / http://localhost:8080/myapp/
ProxyPassReverse / http://localhost:8080/myapp/
Now Wicket 错误地将用户重定向到 /myapp/xxx 而不是 /xxx。
有没有办法让 Wicket(1.3.5) 使用 / 作为我的根路径(而不是 /myapp,它是 servlet 部署上下文路径)?!
编辑:以下链接描述了一个解决方案,但它不适用于 1.3.5 版本: 我找到了它: https://cwiki.apache.org /WICKET/wicket-behind-a-front-end-proxy.html
编辑:问题是 wicket 使用带有 ServletResponse#sendRedirect 的相对路径重定向,而 Tomcat 将它们转换为开头包含 /myapp 的绝对重定向。我尝试过 mod_jk(AJP) 但没有区别!
应该有某种方法告诉 proxy-pass 或 mod-jk 在将重定向发送到客户端之前重写重定向!
I have deployed my Wicket app at /myapp in Tomcat, and I have put it behind Apache web server using
ProxyPass / http://localhost:8080/myapp/
ProxyPassReverse / http://localhost:8080/myapp/
Now Wicket incorrectly redirect users to /myapp/xxx instead of /xxx.
Is there any way to make Wicket(1.3.5) use / as my root path (instead of /myapp which is servlet deployment context path)?!
Edit: There is a solution described at following link but it doesn't works for 1.3.5 version:
I found it: https://cwiki.apache.org/WICKET/wicket-behind-a-front-end-proxy.html
Edit: The problem is that wicket uses relative path redirects with ServletResponse#sendRedirect and Tomcat convert them to absolutes redirects containing /myapp at beginning. I have tried mod_jk(AJP) but there was no difference!
There should be some way to tell proxy-pass or mod-jk to rewrite redirects before sending them to client!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我自己没有测试过,但是你看过 mod_rewrite 吗? 此处有一些示例描述了您想要执行的操作。
Not tested myself, but have you looked at mod_rewrite? There are some examples describing what you want to do here.
我没有找到直接答案,但使用了 mod jk 的以下解决方法,我想也可以使用代理传递。
第一行将来自客户端的以 /myapp/* 开头的请求(这是不正确的 Wicket/Tomcat/Apache 重定向的结果)重定向到 /*。
第二行重写所有从 /* 到 /myapp/* 的请求,第三行将它们发送到 tomcat。
对于代理通行证,第三行应替换为:
I didn't find direct answer but used following workaround with mod jk, I guess it is also possible to do with proxy pass.
First line redirects request coming from client starting with /myapp/* (which are result of incorrect Wicket/Tomcat/Apache redirects) to /*.
Second line rewrites all requests from /* to /myapp/* and third line send them to tomcat.
For proxy pass, third line should be replaced with:
您可能会发现此 Tomcat 文档很有帮助:
http://tomcat.apache.org/connectors -doc/generic_howto/proxy.html
它使用 RedirectMatch 和 mod_rewrite 解决了上述情况。
You may find this Tomcat document helpful:
http://tomcat.apache.org/connectors-doc/generic_howto/proxy.html
It addresses the above situation with RedirectMatch and mod_rewrite.