ProxyPass not working alongside ProxyPassMatch

ProxyPass not working alongside ProxyPassMatch

So at the moment I have a virtual host configured on my Oracle HTTP Server instance with a ProxyPass as such:

ProxyPass ^/test/home/ https://example.com/
ProxyPassMatch ^/test/home/(.*)$ https://example.com/$1
ProxyPassReverse ^/test/home/(.*)$ https://example.com/$1

When I attempt to access https://mywebsite.com/test/home/<url_from_other_server> the request seems to be working as expected. However, when I attempt to access https://mywebsite.com/test/home/ it is not proxying me to https://example.com/ but rather returning a 404.

The ProxyPassMatch wildcard seems to be working for all suburls I attempt to access, but the regular ProxyPass keyword is not.

I have also attempted removing the ProxyPass entirely and I get the same 404 error when attempting to access /test/home/

Does anyone have any idea what could be causing this strange behaviour?

Thank you.

답변1

Your regex is not quite correct. * means "zero or more occurrences", so https://mywebsite.com/test/home/ is matched by it. Change (.*) to (.+), which means "one or more occurrences". Then your ProxyPassMatch should not match that URL anymore.

Or just remove the ProxyPassMatch line completely, it is pretty useless, the urls are handled like it by the ProxyPass line automatically.

ProxyPass /test/home/ https://example.com/
ProxyPassReverse /test/home/ https://example.com/

답변2

The issue has been addressed. The correct configuration for this particular problem is the following:

ProxyPass /test/home(.*)$ https://example.com/$1
ProxyPassReverse /test/home(.*)$ https://example.com/$1

Removing the slash and adding the wildcard has enabled us to proxy anything following /test/home.

Thank you all for your input.

관련 정보