0

I am using my apache container as a reverse-proxy and trying to access one of my VM services. It is working when I configure like,

ProxyPassMatch "^/(.*)$" "https://host1:443/$1"
ProxyPassReverse "^/(.*)$" "https://host1:443/$1"

With the above config I am able to access all the urls of https://host1:443/*. But When I want to access via an explicit worker like,

ProxyPassMatch "^/sample/(.*)$" "https://host1:443/$1"
ProxyPassReverse "^/sample/(.*)$" "https://host1:443/$1

It says "The requested URL /p/login/ was not found on this server." I tried many solutions and couldn't get to work.

1 Answer 1

0
ProxyPassMatch "^/sample/(.*)$" "https://host1:443/$1"

When you only reverse proxy to host1 the URI paths starting with /sample/ requests for /p/login/ shouldn't get forwarded. The requests for /p/login/ will be handled locally by your apache and won't reach host1.

When that path/URI is not present on your apache container that triggers the 404 - file not found error ""The requested URL /p/login/ was not found on this server."

You usually get such an error because the HTML code on host1 links to the absolute path /p/login/ and a common misconception is the reverse proxy would change such a reference to /sample/p/login/ by using the ProxyPassReverse directive. ProxyPassReverse doesn't do that. It only adjusts the URL in the Location, Content-Location and URI headers ; and not in the body/HTML code.

There are several things you can do to resolve that ; as detailed in this answer (Note both your question and that answer are tagged with apache version 2.2 ; the other two answers in that question provide a solution for current version 2.4)

You must log in to answer this question.

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