Apache-2.2

Apache 作為 Nexus、Jenkins 和 Foreman 的代理(同一域、IP 和埠上的多個虛擬主機)

  • July 24, 2013

我想將 Apache 配置為用作 Nexus、Jenkins 和 Foreman 的代理,它們安裝並執行在同一台伺服器上。

這是 Foreman 的虛擬主機配置文件的範例,除了代理傳遞參數之外,Nexus 和 Jenkins 的其他文件看起來幾乎相同。

LoadModule ssl_module modules/mod_ssl.so
NameVirtualHost *:443
<VirtualHost *:443>
 SSLEngine On
 SSLProxyEngine On
 SSLCertificateFile /etc/httpd/ssl/certs/ssl.crt
 SSLCertificateKeyFile /etc/httpd/ssl/keys/server.key

 ServerName management.domain.com

 <Proxy *>
    Order deny,allow
    Allow from all
 </Proxy>

 ProxyPass        /foreman http://127.0.0.1:3000/foreman
 ProxyPassReverse /foreman http://127.0.0.1:3000/foreman
 ProxyPassReverse /foreman http://management.domain.com/foreman

 ProxyRequests Off
 ProxyPreserveHost On

 ErrorLog /var/log/httpd/management.domain.com_foreman_error.log
 LogLevel warn
 CustomLog /var/log/httpd/management.domain.com_foreman_access.log combined
</VirtualHost>

問題是 Apache 只考慮了一個配置文件而忽略了另外兩個導致錯誤消息**“在此伺服器上找不到請求的 URL /jenkins/”。**當我嘗試訪問 URL management.domain.com/jenkins

如何配置 Apache 載入三個虛擬主機?謝謝

PS:Listen 指令在 httpd.conf (= 443) 中聲明

如果您使用一個伺服器名稱,它將無法按您的意願工作。您所需要做的就是將 3 個虛擬主機合併到一個中。就像是

LoadModule ssl_module modules/mod_ssl.so
NameVirtualHost *:443
<VirtualHost *:443>
 SSLEngine On
 SSLProxyEngine On
 SSLCertificateFile /etc/httpd/ssl/certs/ssl.crt
 SSLCertificateKeyFile /etc/httpd/ssl/keys/server.key

 ProxyRequests Off
 ProxyPreserveHost On

 ServerName management.domain.com

 <Proxy *>
    Order deny,allow
    Allow from all
 </Proxy>

 ProxyPass        /foreman http://127.0.0.1:3000/foreman
 ProxyPassReverse /foreman http://127.0.0.1:3000/foreman
 ProxyPassReverse /foreman http://management.domain.com/foreman

 ProxyPass        /nexus http://127.0.0.1:3000/nexus
 ProxyPassReverse /nexus http://127.0.0.1:3000/nexus
 ProxyPassReverse /nexus http://management.domain.com/nexus

 ProxyPass        /jenkins http://127.0.0.1:3000/jenkins
 ProxyPassReverse /jenkins http://127.0.0.1:3000/jenkins
 ProxyPassReverse /jenkins http://management.domain.com/jenkins

引用自:https://serverfault.com/questions/525861