我有一個Java應用程序響應多個域,併爲每個域使用特定的apache虛擬主機。這是因爲Apache比tomcat更快,可以提供靜態資源。apache虛擬主機和「動態」域
需要在運行時執行此操作,而無需重新啓動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.comto domain.com的符號鏈接是個好主意嗎?
存在另一種方式來做到這一點?我在apache管理方面真的很差...
非常感謝!
Ciao,Davide。