user5479362
user5479362

Reputation:

Apache LocationMatch matching urls starting with...

I'm using apache to redirect AJAX request to server backend in my AJAX app.

Everything that starts with /service/ should go to service backend:

<LocationMatch "/service">
    ProxyPass http://backend:8080/service Keepalive=On
    Header set Cache-Control "no-cache, no-store, must-revalidate"
</LocationMatch>

Everything that starts with /auth goes to authentication server:

<LocationMatch "/auth">
    ProxyPass http://keycloak:8090/auth/ Keepalive=On
</LocationMatch>

I was happy with my apparently working solution, unless the auth channel was added to backend, and them I've noticed, that requests to /service/auth/info are not consumed by backend, but land in authentication server.

Apparently I have some understanding problem. How should I match URLs that start with given string, and not contain it somewhere in the middle?

Upvotes: 2

Views: 3470

Answers (1)

Gary Browne
Gary Browne

Reputation: 77

Use the caret (^) to indicate the beginning of the string:

<LocationMatch "^/service">

Upvotes: 2

Related Questions