Skip to content

Instantly share code, notes, and snippets.

@beije
Last active February 26, 2021 18:58
Show Gist options
  • Save beije/5689935 to your computer and use it in GitHub Desktop.
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.
<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
Copy link

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