更新时间:2023-11-22 19:19:40
您不需要多个 Tomcat 实例 - 您可以将多个客户端指向多个子域以使用同一个 Web 应用程序
You dont need multiple Tomcat instances - you can point multiple clients across multiple subdomains to use the same web app
但请确保这适合您的业务用例 - 即您是否确实希望运行多个 web 应用程序实例,或者一个可以为所有客户服务的单个实例.
BUT be sure that this fits with your business use case - i.e. do you actually want multiple instances of the webapp running, or a can single instance serve all your clients.
我指的是品牌/徽标/共享数据/外观等 - 所有客户都这样吗?
I'm referring to the branding/logo/shared data/look-and-feel etc - is that common across all clients?
让我们假设它是.
配置 Apache 后,正确的方法是使用 VirtualHost
指令和 mod_proxy.
With an Apache configured, the right way is to use VirtualHost
directives along with mod_proxy.
Apache 端这样的配置应该可以工作 - 每个子域创建一个,并将 ProxyPass
和 ProxyPassReverse
指向 Tomcat Web 应用程序
A configuration like this on the Apache side should work - create one per subdomain, and point the ProxyPass
and ProxyPassReverse
to the Tomcat web app
<VirtualHost *:80>
ServerName client1.domain.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /jwa http://client1.domain.com:8080/jwa
ProxyPassReverse /jwa http://client1.domain.com:8080/jwa
</VirtualHost>
相关阅读
Apache 文档 有很多 VirtualHost 配置示例
还有一个没有 Apache httpd 的解决方案,您可以在 Tomcat server.xml 中配置 Host 整体,但 Apache 是管理域 URL 的更好地方
There is also a solution without Apache httpd, you can configure Host entires within Tomcat server.xml but Apache is a better place to manage your domain URLs