Apache – How to Merge Multiple ProxyPass Directives

apache-2.2configuration

I need to keep ProxyPass configurations in separate files due to deployment system we use in following form:

File 1:

<VirtualHost *:80>
    <Location /qa1/>
        ProxyPass http://localhost:8800/qa1/
        ProxyPassReverse http://localhost:8800/qa1/
        ProxyPassReverseCookiePath / /qa1/
    </Location>
</VirtualHost>

File 2:

<VirtualHost *:80>
    <Location /qa2/>
        ProxyPass http://localhost:8801/qa2/
        ProxyPassReverse http://localhost:8801/qa2/
        ProxyPassReverseCookiePath / /qa2/
    </Location>
</VirtualHost>

but Apache complains that:
[warn] default VirtualHost overlap on port 80, the first has precedence

Any idea if/how it possible to have Apache merge the both configurations?

Best Answer

Use Include.

File 1: qa1.conf

<Location /qa1/>
    ProxyPass http://localhost:8800/qa1/
    ProxyPassReverse http://localhost:8800/qa1/
    ProxyPassReverseCookiePath / /qa1/
</Location>

File 2: qa2.conf

<Location /qa2/>
    ProxyPass http://localhost:8801/qa2/
    ProxyPassReverse http://localhost:8801/qa2/
    ProxyPassReverseCookiePath / /qa2/
</Location>

File 3: vhost.conf

<VirtualHost *:80>
    Include qa1.conf
    Include qa2.conf
</VirtualHost>