Last active
February 26, 2021 18:58
-
-
Save beije/5689935 to your computer and use it in GitHub Desktop.
An example apache virtual host config for internal proxying. A wonderous hack if you lack control of DNS servers and need to test a site on a device that doesn't let you modify the hosts file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerName 10.0.0.10 | |
# Set url to proxy | |
ProxyPass / http://hosts.domain.dev/ | |
ProxyPassReverse / http://hosts.domain.dev/ | |
# Set location | |
<location /> | |
# Set url | |
ProxyPass http://hosts.domain.dev/ | |
# Ouput html from proxy filter | |
SetOutputFilter proxy-html | |
# Add referer hack (if the site uses referrer as security) | |
Header add referer "http://hosts.domain.dev" | |
RequestHeader set referer "http://hosts.domain.dev" | |
# Overwrite html, exchange urls with proxied (like href, src, etc.) | |
ProxyHTMLExtended On | |
ProxyHTMLURLMap http://hosts.domain.dev http://10.0.0.10 | |
# For items that use style="background-image:url()" | |
ProxyHTMLEvents style | |
# You can add more url maps to overwrite if there are subdomains | |
# that you want/need to override | |
ProxyHTMLURLMap http://static.domain.dev http://10.0.0.10 | |
# Rewrite Cookie domain if the site uses sessions as an identifier | |
# i.e. PHPSESSID | |
ProxyPassReverseCookieDomain .domain.dev 10.0.0.10 | |
</location> | |
</VirtualHost> |
@DieselDriver I can't say why it's not working without setting it up, but my initial hunch would be that not all the requests are made against medium.com but through other hosts, e.g. cdn's etc. You'd probably have to set up proxies against those URL's as well.
The relevant request for the main content is made against medium.com and I think they check the referer in other way as usual.
It's an interessting problem - this is the first website that makes troubles with a reverse proxy. :-(
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Benjamin,
why does the reverse proxy does not work for e.g. https://medium.com/dronehub?
The index page works, also the replacing of href but the submenus only show an error 404.
Is there any other security feature used by medium.com or is it a problem of the header which will be returned by the reverse proxy?
I see that medium.com uses json calls which have other behavior than when the website will be opened through the medium.com URL (the network sniffer contains different requests) .
I hope you have an idea.
Thanks.