Friday, July 26, 2013

Reverse proxy with CORS usin Apache2

For the implementation of a Javascript-Client, I needed a CORS enabled reverse-proxy.

Here is one using apache2 (Virtual Host):
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so 
LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so


 ProxyRequests Off

 ProxyPass / http://SERVER
 ProxyPassReverse / http://SERVER

 Header set Access-Control-Allow-Origin "*"
 Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"

Here is one using apache2 (.htaccess): mod_rewrite and mod_headers must be loaded.
RewriteEngine  On
RewriteBase /
RewriteRule  (.*)  http://SERVER/$1  [P,L]

 Header set Access-Control-Allow-Origin "*"
 Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
PS: Be aware of the security implications!

1 comment:

  1. Now I have a alternate and short method to open any blocked site very easily in just one click and you can open any site very easily.
    Fenopy UK proxy

    ReplyDelete

Note: Only a member of this blog may post a comment.