How to merge multiple ProxyPass directives in Apache?

Solution 1:

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>

Solution 2:

just keep the Location directives separately

file qa1.conf

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

file qa2.conf

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

then

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