0

I've got the following minimal test case on Apache 2.4.6:

<VirtualHost *:80>
    # Match all paths excluding /proxy
    <LocationMatch ^/prefix/((?!proxy/).*)$>
        ProxyPassMatch http://127.0.0.1:8082/$1
    </LocationMatch>

    # Match /proxy specifically
    <Location /prefix/proxy/>
        ProxyPass "http://127.0.0.1:8082/proxy/"
    </Location>
</VirtualHost>

(The two locations do the same thing here, but they'll be configured differently on a production machine, of course.)

When trying to run Apache with this config, it fails with the following error:

AH00526: Syntax error on line 7 of /etc/httpd/conf.d/broken.conf:
ProxyPass/<Proxy> and ProxyPassMatch/<ProxyMatch> can't be used altogether
  with the same worker name (http://127.0.0.1:8082/$1)

I can't figure out what the error message means (it's not even proper English!) and how to solve it. From what I see, the ProxyPass worker names are different - they must be different, since the URLs are mutually exclusive!

Google returns only 3 hits for the error, and two of them point to the Apache source code. If I remove either one of the directives on line 3 and line 7, the config works fine.

1 Answer 1

2

The way you are defining your proxy pass directives make these kind of weird issues possible.

The main error is you are defining the same target twice with the same matching path one with regex and the other without.

You make another mistake. Do not mix ProxyPass and Location. That is mixing a directive that can take a uri-path with another that refers a uri-path but works differently, that is ProxyPass first parameter in virtualhost is a uri-path, and Location refers to uri-path too but its precedence is different (Location with most global path should be defined first,but proxypass works the opposite way), so why mix them? Unless you want to make it difficult to read, you shouldn't.

So, briefly your fix, just use ProxyPass in the correct order or precedence and it will be more simple to read, to configure and will do exactly what you seek:

<VirtualHost *:80>
    ProxyPass /prefix/proxy/ http://127.0.0.1:8082/proxy/
    ProxyPass /prefix/ http://127.0.0.1:8082/
</VirtualHost>

Note: Should you need to apply specific directives like auth or whatnot to one of these uris then you can use Location separately.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .