我希望能够转发 url,例如
http://external_url.com/auth => http://internal_url.com:8080/app/auth
https://external_url.com/w/my-account => https://internal_url.com:8080/app/LogIn.do
https://external_url.com/w/forgot-password => https://internal_url.com:8080/app/ForgotPassword.do
https://external_url.com/w/register-user => https://internal_url.com:8080/app/CustomerRegistration.do
http://external_url.com/w/logout => https://internal_url.com:8080/app/LogIn.do
我已经能够将标准镜像 url 转发到 tomcat 应用程序,但无法为自定义 external_url 这样做,有什么想法吗?
我尝试使用 ProxyPathMatch
:
ProxyPathMatch ^(/\/w\/forgot\-password)$ http://internal_url.com:8080 /app/ForgotPassword.do
但是 Apache 提示说它不正确。
非常感谢您的帮助。
最佳答案
mod_jk 不像 mod_proxy,因为您可以用这种方式重写 URL。你可以这样做:
JkMount /auth myAuthApp
然后在worker.properties中定义合适的应用:
worker.list=myAuthApp
worker.myAuthApp.host=internal_url.com
worker.myAuthApp.port=8080
但是您的 tomcat 应用程序必须能够监听正确的上下文路径。在这种情况下,它将是/auth,而不是/app/auth。
您可以使用 cookie、URI 等进行各种巧妙的转发。但应用程序仍将获得原始路径,并且必须能够响应它。
http://tomcat.apache.org/connectors-doc/reference/apache.html
关于apache - 自定义 mod_jk 转发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6365073/