I'm trying to build a web site that let's you view and manipulate data from any page in any other website. To do that, I have to bypass '
Allow Origin' problems: i'm loading the other domain's content in an
My first attempt was to write a simple proxy myself, requesting the other domains page through a server proxy coded in Java that not only serves the content but rebuilds links (src's and href's) in the content so that the content referenced by these links alse get downloaded through my handmade proxy. The result is not bad but has problems with url's in css and scripts.
It's then that i realized that
mod_proxy_html is supposed to do exactly all this job. The problem is that i cannot figure out how to make it work as expected.
Let's suppose my server runs in my-domain.com and to proxy and transform content from another domain i'd make a request like this:
mod_proxy_html to serve the content and rewrite following URLs in
http://another-domain.com/some/content in the following ways:
- Absolute URLs not from
another-domain.com: no rewritting
- Relative from root urls:
- Relative urls:
- Relative to parent urls:
The url should be specified at runtime, not configuration time.
Can this be achieved with mod_proxy_html? Could anyone provide a simple working configuration to start with?
EDIT 1-First approach
The following site config will work fine with sites that use absolute url's everywhere like
http://www.huffingtonpost.es/. Youc could try on this config on localhost:
<VirtualHost *:80> ServerName localhost LogLevel debug ProxyRequests off RewriteEngine On RewriteRule ^/asset/(.*) $1 [P] ProxyHTMLURLMap $1 /asset/ <Location /asset/> ProxyPassReverse / ProxyHTMLURLMap / /asset/ </Location> </VirtualHost>
But as explained in the documentation, if I hit a site using relative url's, I'd like to have these rewritten on the html via mod_proxy_html. So I shoud change the
Location block as follows:
<Location /asset/> ProxyPassReverse / #Depending on your system use one line or the other #Ubuntu: #SetOutputFilter proxy-html #any other system: ProxyHTMLEnable On ProxyHTMLURLMap / /asset/ </Location>
...which doesn't seem to work. Comments, hints and ideas welcome!