I have a bunch of subdomains in one single server:
All of them are in the same Apache virtualhost.
I need to use a feed provided by the news subdomain inside the a and b subdomain. The feeds typically look like this:
I was able to override this by adding the
Access-Control-Allow-Origin "*" to my Apache config file.
... but this works only in Firefox, Chrome and Safari. Internet explorer seems to ignore that directive.
Thus, I need to create a proxy.
What I need is a new directory in all my subcomains (for example
/proxy) that Apache detects, and redirects to news.example.com, no matter what the subdomain. So:
<li>a.example.com/proxy/news/a -> return the contents of news.example.com/news/a</li>
<li>b.example.com/proxy/news/b -> return the contents of news.example.com/news/b</li>
Can I do this directly in Apache + submodules (for example, mod_rewrite), or do I need to use a scripting language like PHP for doing this?
You want the ProxyPass Directive.
ProxyPass /proxy/news/a http://news.example.com/news/a
At the end we were able to make the proxy using a combination of two modules:
The syntax was the following:
rewriteEngine on rewriteRule proxy/(.+)$ http://news.example.com/$1 [P]
The [P] at the end is telling the rule "act as a proxy" and doesn't work without mod_proxy. Without it, apache makes a "redirect" (the url at the top of the page changes) instead of "just serving the page".
Apache can be configured to use apache:
consider this working sample code (proxy part):
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName ci.testserver.com ServerAlias ci ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPreserveHost on ProxyPass / http://localhost:8080/ </VirtualHost>