ProxyPass|ProxyPassMatch can not have a path when defined in a location

Chalaka Ellawala picture Chalaka Ellawala · Oct 4, 2016 · Viewed 13.1k times · Source

I tried the answer in this problem. How to merge multiple ProxyPass directives in Apache? But I am getting an error when I am starting apache saying ProxyPass|ProxyPassMatch can not have a path when defined in a location.

My 000-default.conf has below code

<VirtualHost *:80>
include location1.conf
include location2.conf
</VirtualHost>

and my location1 has,

<Location /web/?_escaped_fragment_=/>
ProxyPass        /phpmyadmin !
ProxyPass / http://localhost:8082/
ProxyPassReverse / http://localhost:8082/
</Location>

and my location2 has,

<Location /web/#!/>
ProxyPass        /phpmyadmin !
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</Location>

Answer

helvete picture helvete · Feb 16, 2018

Similarly as can be seen in the question you mention, there is a necessity to drop the first argument of the ProxyPass and ProxyPassReverse clauses when nested under <Location> clause.

So consider altering your config like this:

location1:

<Location /web/?_escaped_fragment_=/>
    ProxyPass /phpmyadmin !
    ProxyPass http://localhost:8082/          # <== Dropped '/'
    ProxyPassReverse http://localhost:8082/   # <== Dropped '/'
</Location>

location2:

<Location /web/#!/>
    ProxyPass /phpmyadmin !
    ProxyPass http://localhost:8080/          # <== Dropped '/'
    ProxyPassReverse http://localhost:8080/   # <== Dropped '/'
</Location>

This should work fine.