Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
corrected error in config
Source Link
Joe Sniderman
  • 2.8k
  • 1
  • 24
  • 26

You need to use a single virtual host to handle both!

Apache matches vhosts based on the HTTP Host header. Since the hostname is the same regardless of whether a client is accessing redmine or jenkins, both must in the same vhost.

What is happening with your current configuration is that Apache is determining which vhost to match as soon as it sees the Host header. Because 'j' comes before 'r' alphabetically, it is giving priority to your jenkins vhost file, even though both match.

You are trying to match based on the request URI, and proxy accordingly.

The <Proxy> directive already has this functionality built in!

You could use something like the following in a single vhost to accomplish your objective:

<VirtualHost *:80> ServerAdmin [email protected] ServerName sub.domain.com ProxyRequests Off <Proxy http://sub.domain.com/jenkins> Order deny,allow Allow from all ProxyPreserveHost off ProxyPass /jenkins http://localhost:8080/jenkins ProxyPassReverse /jenkins http://localhost:8080/jenkins </Proxy> <Proxy http://sub.domain.com/redmine> Order deny,allow Allow from all ProxyPreserveHost off ProxyPass /redmine http://localhost:8081/redmine ProxyPassReverse /redmine http://localhost:8081/redmine </Proxy> </VirtualHost> 

You need to use a single virtual host to handle both!

Apache matches vhosts based on the HTTP Host header. Since the hostname is the same regardless of whether a client is accessing redmine or jenkins, both must in the same vhost.

What is happening with your current configuration is that Apache is determining which vhost to match as soon as it sees the Host header. Because 'j' comes before 'r' alphabetically, it is giving priority to your jenkins vhost file, even though both match.

You are trying to match based on the request URI, and proxy accordingly.

The <Proxy> directive already has this functionality built in!

You could use something like the following in a single vhost to accomplish your objective:

<VirtualHost *:80> ServerAdmin [email protected] ServerName sub.domain.com ProxyRequests Off <Proxy http://sub.domain.com/jenkins> Order deny,allow Allow from all ProxyPreserveHost off ProxyPass /jenkins http://localhost:8080/jenkins ProxyPassReverse /jenkins http://localhost:8080/jenkins </Proxy> <Proxy http://sub.domain.com/redmine> Order deny,allow Allow from all ProxyPreserveHost off ProxyPass /redmine http://localhost:8081/redmine ProxyPassReverse /redmine http://localhost:8081/redmine </Proxy> </VirtualHost> 

You need to use a single virtual host to handle both!

Apache matches vhosts based on the HTTP Host header. Since the hostname is the same regardless of whether a client is accessing redmine or jenkins, both must in the same vhost.

What is happening with your current configuration is that Apache is determining which vhost to match as soon as it sees the Host header. Because 'j' comes before 'r' alphabetically, it is giving priority to your jenkins vhost file, even though both match.

You are trying to match based on the request URI, and proxy accordingly.

The <Proxy> directive already has this functionality built in!

You could use something like the following in a single vhost to accomplish your objective:

<VirtualHost *:80> ServerAdmin [email protected] ServerName sub.domain.com ProxyRequests Off <Proxy http://sub.domain.com/jenkins> Order deny,allow Allow from all ProxyPreserveHost off ProxyPass http://localhost:8080/jenkins ProxyPassReverse http://localhost:8080/jenkins </Proxy> <Proxy http://sub.domain.com/redmine> Order deny,allow Allow from all ProxyPreserveHost off ProxyPass http://localhost:8081/redmine ProxyPassReverse http://localhost:8081/redmine </Proxy> </VirtualHost> 
Source Link
Joe Sniderman
  • 2.8k
  • 1
  • 24
  • 26

You need to use a single virtual host to handle both!

Apache matches vhosts based on the HTTP Host header. Since the hostname is the same regardless of whether a client is accessing redmine or jenkins, both must in the same vhost.

What is happening with your current configuration is that Apache is determining which vhost to match as soon as it sees the Host header. Because 'j' comes before 'r' alphabetically, it is giving priority to your jenkins vhost file, even though both match.

You are trying to match based on the request URI, and proxy accordingly.

The <Proxy> directive already has this functionality built in!

You could use something like the following in a single vhost to accomplish your objective:

<VirtualHost *:80> ServerAdmin [email protected] ServerName sub.domain.com ProxyRequests Off <Proxy http://sub.domain.com/jenkins> Order deny,allow Allow from all ProxyPreserveHost off ProxyPass /jenkins http://localhost:8080/jenkins ProxyPassReverse /jenkins http://localhost:8080/jenkins </Proxy> <Proxy http://sub.domain.com/redmine> Order deny,allow Allow from all ProxyPreserveHost off ProxyPass /redmine http://localhost:8081/redmine ProxyPassReverse /redmine http://localhost:8081/redmine </Proxy> </VirtualHost>