Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like to configure Apache to be used as a proxy for Nexus, Jenkins and Foreman which are installed and running on the same server.

Here is an example of the Virtual host config file for Foreman, the others files for Nexus and Jenkins looks pretty the same except the proxy pass parameters.

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>

The problem is that Apache takes in account only one config file and ignores the two others which leads to the error message "The requested URL /jenkins/ was not found on this server." when I try to access the URL management.domain.com/jenkins

How to configure Apache to load the three virtual hosts ? Thanks

PS: the Listen directive is declared in httpd.conf (= 443)

share|improve this question

1 Answer 1

up vote 2 down vote accepted

If you use one servername it wouldn't work as you want. All you need is to merge 3 virt host in to the one. Something like

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
share|improve this answer
    
Thank you ALex_hha! it works :) –  PapelPincel Jul 24 '13 at 14:11
    
What if I declare 3 different Virtual hosts with different ServerName directive ? ServerName nexus.domain.com, ServerName jenkins.domain.com and foreman.domain.com I'll give it a shot... –  PapelPincel Jul 24 '13 at 14:13
    
If you will use 3 different servername it would work fine even on one ip address (with SNI). The problem is that when apache look virtualhost configuration it will apply first match. As far as I know, even order of definition vhosts (name of the files) does the matter –  ALex_hha Jul 24 '13 at 15:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.