Reverse proxy with mod_proxy, preserve original request URL

15,638

Fixed with:

ProxyPreserveHost On
ProxyRequests Off
ProxyPass /foo http://127.0.0.1:8080/foo
ProxyPassReverse /foo http://127.0.0.1:8080/foo
Share:
15,638
Mark
Author by

Mark

Updated on June 05, 2022

Comments

  • Mark
    Mark almost 2 years

    I've configured a reverse proxy using mod_proxy (Apache2) listening on 127.0.0.1:80, that proxies all the request to 127.0.0.1:8080

    So I've configured mod_proxy like:

    ProxyPreserveHost On
    ProxyRequests Off
    ProxyPass /foo http://127.0.0.1:8080
    ProxyPassReverse /foo http://127.0.0.1:8080
    

    When I request http://127.0.0.1/foo/bar, the app listening on 127.0.0.1:8080 gets the following request URL from mod_proxy:

    http://127.0.0.1/bar

    Instead I'd like to preserve the original request, and get:

    http://127.0.0.1/foo/bar

    How can I do this?

  • Mohsin Javed Cheema
    Mohsin Javed Cheema about 9 years
    while this is correct can we do this that /foo is running 127.0.0.1 and not with foo after it, So that localhost/foo is actually running 127.0.0.1