您好Stackoverflow社區,如何獲得VHost服務器名稱與Java?
我越來越有點混淆與獲取Vhost的Servername。我正在使用我的apache和Tomcat。 Apache將請求重定向到我的Tomcat以啓動一個函數。 重點是我必須識別Servername。目的是獲取服務器名稱並決定服務器名稱是否類似於office23.de,然後服務器必須加載office23的配置,如果其他辦公室然後加載其他配置。我希望我能解釋一下。
我做了什麼至今:
我加入到Tomcat的server.xml:
也加入Apache的httpd.conf:
ProxyRequests on
ProxyPass /getTest/ http://localhost:8080/Test/
ProxyPassReverse /getTest/ http://localhost:8080/test/
和線加載mod_proxy的東西。
另外我配置的httpd-vhosts.conf這樣的:
服務器名js.local.test.de
DocumentRoot "D:/downloads/xampp/tomcat/webapps"
<Directory />
Require all granted
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "D:/downloads/xampp/apache/logs/virtualHost.log"
CustomLog "D:/downloads/xampp/apache/logs/customLog.log" common
我可以通過虛擬主機ADRESS達到我的應用程序,但當我嘗試獲取主機頭時,它說它的localhost:8080。
我也改變了windows的hostfile。
是否有任何讓我獲得虛擬主機名稱的弊端?
非常感謝你,這工作完美! –
@ArturRem你非常歡迎。 – mrjink
你無法想象你幫了我多少錢:-) –