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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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. :-(