I'm trying to make a reverse proxy to my router's web interface with apache in the subdirectory /lan/

My router's IP address is and can be accessed through

I'm using the following directives to try to accomplish this:

    <Location /lan>

The problem is that is rewrites or to https://my.domain/.js or https://my.dmain/.css instead of https://my.domain/lan/.js and https://my.domain/lan/.css

I was able to get this exact setup to work with pihole with these directives:

    <Location /pi-hole>

and it properly rewrites everything under /admin/ instead of the root

I have tried several things but nothing has worked I'd really appreciate any help


The URLs for the .css and .js files are generated by the router itself, and they are located inside the HTML code your router sends to your client.

Apache does not modify HTML response bodies with ProxyPassReverse, it only modifies response headers.

You need to use Apache's mod_substitute for replacing the response body. You can find more information on it at https://httpd.apache.org/docs/current/mod/mod_substitute.html.

You need to be careful when specifying the rules for mod_substitute, since changing the HTML body in incorrect ways can make the whole admin interface to work incorrectly.

A better way would be to use a subdomain for the reverse proxy.

  • I cant check if this resolves the issue right now but if i does I'll be sure to give you the correct answer. I want to avoid using a subdomain because then people can easily connect by doing a dns lookup on my domain, and I use cloudflare so I won't be able to enforce a maximum number of attempts or else that will kill ALL traffic from cloudflare, not just the attacker. – Desultory Aug 8 '17 at 15:44
  • I am not sure if I understood your text correctly, but there can be subdomains also in Cloudflare, and those are protected in the same way as the main domain. – Tero Kilkanen Aug 8 '17 at 15:59
  • yes and no, I use fail2ban with the apache_auth mod enabled, if someone accessing a site through a cloudflared IP triggers that jail then the cloudflare IP they went through is banned and that makes it so that most, if not all cloudflare users accessing my site will be told the site is offline, unless there is some way to get fail2ban to ban the origin ip, running sites with authentication over coudflared ips causes bad problems – Desultory Aug 8 '17 at 20:41
  • I am sure there is a way for Apache to use Cloudflare's header for the client IP instead of Cloudflare IP address for its operation. In nginx, one can use set_real_ip directive for this. – Tero Kilkanen Aug 9 '17 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.