我正在尝试使用后端tomcat应用程序的不同URL配置外部Apache前端。我以tomcat的管理器应用程序为例。
我想让用户像外部一样访问我的页面:https://myhost.com/tomcat-manager
在内部,它被重定向到http://localhost:8080/manager
我使用mod_proxy和mod_rewrite在apache2中尝试了以下配置:
RewriteEngine on
SSLProxyEngine on
RewriteRule "/manager/(.*)$" https://myhost.com/tomcat-manager/$1 [P]
ProxyPass /tomcat-manager http://localhost:8080/manager
ProxyPassReverse /tomcat-manager http://localhost:8080/manager它基本上可以工作,但我不喜欢tomcat manager webapp将其链接输出为"/manager“而不是"/tomcat-manager",这迫使我添加了上面的mod_rewrite规则。理想情况下,我希望最终用户只能看到模式的浏览器URL:
https://myhost.com/tomcat-manager/(whatever)
而且永远不会有以下情况:
https://myhost.com/manager/(whatever)
在不修改底层webapp的情况下配置Apache有什么建议吗?谢谢!
发布于 2018-10-16 14:29:39
我找到了我问题的答案。这是Apache的mod_proxy_html。我启用了相应的模块,并修复了Ubuntu缺少的mod_proxy_html配置,如下所示:https://serverfault.com/questions/684905/proxyhtmlurlmap-not-working-in-apache2-4
然后,我添加了以下配置代码:
ProxyHTMLEnable On
ProxyHTMLURLMap http://localhost:8080/manager/ /tomcat-manager/
ProxyHTMLURLMap /manager/ /tomcat-manager/
SetOutputFilter proxy-html
RequestHeader unset Accept-Encoding就是这样。现在,我可以访问http://myhost.com/tomcat-manager了,里面的html代码也被重写了!
https://stackoverflow.com/questions/52827017
复制相似问题