Apache - Tomcat ProxyPass VirtualHost - 上下文路径
我在为 tomcat 中有两个不同上下文路径的两个应用程序配置 apache tomcat ProxyPass 指令时遇到问题。 tomcat 在 apache 后面运行,我使用 apache 来代理 tomcat 的请求路径。在 apache 中,我想通过主机名而不是上下文路径访问这两个应用程序。
场景:
tomcat 中的tomcat
https://domain:8443/app1
https://domain:8443/app2
应用程序在 apache 中具有上下文路径 app1 和 app2
我想启用这两个应用程序,如下所示:
https://app1.host/
https://app2.host/
在 apache 中,我为每个域创建了一个配置:
ProxyPass / https://localhost:8443/app1
ProxyPassReverse / https://localhost:/8443/app1
奇怪的是 app1 只能通过 apache 使用上下文路径使用:
https://app1.host/app1
是否可以使用apache ProxyPass模块实现这样的设置?
谢谢你的帮助。
I have a problem configuring apache tomcat ProxyPass directive for two applications that have two different Context Paths in tomcat. The tomcat is running behind an apache and I use the apache to proxy path the requests to tomcat. In apache I want to access both application via a hostname instead of a context path.
Scenario:
tomcat
https://domain:8443/app1
https://domain:8443/app2
in tomcat the applications have the context path app1 and app2
in apache I want to enable both application as follow:
https://app1.host/
https://app2.host/
In apache I have created a configuration for each domain:
ProxyPass / https://localhost:8443/app1
ProxyPassReverse / https://localhost:/8443/app1
The strange thing is app1 is only available through apache using the context path:
https://app1.host/app1
Is it possible to realize such a setup with apache ProxyPass module?
Thx for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过使用虚拟主机,您应该能够达到您想要的结果。另外,通过 AJP 协议而不是 HTTPS 将请求传递给 tomcat 也是一个好主意。尝试将其添加到 Apache 配置中,
如果您尚未更改 Tomcat 的默认服务器设置,那么这应该可以正常工作。否则,请确保指定在 Tomcat 的 conf/server.xml 文件中配置的 AJP 端口。应该有类似这样的一行:
确保您在 Apache 配置中加载了 mod_proxy 和 mod_proxy_ajp 模块,这可能会根据您的 Apache 安装而有所不同。还要删除任何先前配置的“ProxyPass / ...”行,因为它们会干扰新配置。希望这对你有用。
You should be able to achieve the result you want by using virtual hosting. Also it's a good idea to pass the requests to tomcat via the AJP protocol instead of HTTPS. Try adding this to the Apache configuration
If you haven't changed the default server settings for Tomcat this should work just as it is. Otherwise make sure to specify the AJP port that is configured in Tomcat's conf/server.xml file. There should be a line similar to this:
Make sure that you have the mod_proxy and mod_proxy_ajp modules loaded in Apache configuration, this may vary depending on your Apache installation. Also remove any previously configured 'ProxyPass / ...' lines as they will interfere with the new configuration. Hope this works for you.
你可以尝试
最后的/
you can try
with the final /