0

I am trying to forward a subdirectory to a docker setup using Apache proxy and reverseproxy using Apache on a Linux server

Here is the example

<Location /foo/>

RewriteEngine On
ProxyPreserveHost Off

proxypass http://docker_host:8233/
ProxyPassReverse http://docker_host:8233/
ProxyPassReverseCookieDomain  "http://Docker_host:8233/"  "https://example.com/foo/"
ProxyPassReverseCookiePath  "/"  "/foo/"

</Location>

What ends up happening is that when a GET request is sent to https://example.com/foo/ the docker responds with a 302 Found and it sends the location as /welcome/login/

Then my browser redirects to https://example.com/welcome/login/ instead of what i am trying to redirect to, which is https://example.com/foo/welcome/login/

this ultimately fails in loading the webpage as the resources needed are not pulled.

I followed the apache docs to do this, as listed here:

path is the name of a local virtual path; url is a partial URL for the remote server. These parameters are used the same way as for the ProxyPass directive.

For example, suppose the local server has address http://example.com/; then

ProxyPass         "/mirror/foo/" "http://backend.example.com/"
ProxyPassReverse  "/mirror/foo/" "http://backend.example.com/"
ProxyPassReverseCookieDomain  "backend.example.com"  "public.example.com"
ProxyPassReverseCookiePath  "/"  "/mirror/foo/"

will not only cause a local request for the http://example.com/mirror/foo/bar to be internally converted into a proxy request to http://backend.example.com/bar (the functionality which ProxyPass provides here). It also takes care of redirects which the server backend.example.com sends when redirecting http://backend.example.com/bar to http://backend.example.com/quux . Apache httpd adjusts this to http://example.com/mirror/foo/quux before forwarding the HTTP redirect response to the client. Note that the hostname used for constructing the URL is chosen in respect to the setting of the UseCanonicalName directive.

When used inside a section, the first argument is omitted and the local directory is obtained from the . The same occurs inside a section, but will probably not work as intended, as ProxyPassReverse will interpret the regexp literally as a path; if needed in this situation, specify the ProxyPassReverse outside the section or in a separate section.

When looking at the apache docs this exact scenario seems to be accounted for however it is failing, any suggestions?

0

You must log in to answer this question.

Browse other questions tagged .