【发布时间】:2011-08-04 10:24:11
【问题描述】:
我有一个 java 应用程序响应多个域,并为每个域使用一个特定的 apache 虚拟主机。这是因为 Apache 在提供静态资源方面比 tomcat 更快。
需要在运行时执行此操作,而无需重新启动 apache 配置。 要执行此操作,我使用 VirtualDocumentRoot 指令,如下所述:
AddType text/html .html .shtml
AddOutputFilter INCLUDES .html .shtml
NameVirtualHost *:80
UseCanonicalName Off
<VirtualHost *:80>
ServerName domain.com
ServerAlias *
# Define virtual host directory, using entire domain
VirtualDocumentRoot /path/to/whosts/%0
# Define directory access
<Directory "/path/to/whosts/">
Options -Indexes MultiViews +Includes
Order allow,deny
Allow from all
</Directory>
# Define Java Proxies
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
# Allow Libs (static resources) to access apache directly
ProxyPass /libs !
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
</VirtualHost>
这不好用,因为如果我尝试访问 www.domain.com,与访问 domain.com 不同。
你认为注册一个从 www.domain.com 到 domain.com 的符号链接是个好主意吗???
存在另一种方法吗?我在 apache 管理方面真的很差......
非常感谢!
Ciao,大卫。
【问题讨论】:
标签: apache dynamic alias virtualhost restart