Reverse Proxy Config in Apache + XAMPP
People have heard about the regular Proxy servers. A proxy server is a server that acts as an intermediary for requests from clients seeking resources from other servers. Some proxy servers are intelligent enough to cache the content to serve faster based on the request URL.
There is one more Proxy called reverse proxy which accepts the requests from client and forwards to the actual server or other proxy servers to handle the request. The response from the proxy server is returned as if it came directly from the original server, leaving the client no knowledge of the origin servers
How i used this feature locally ? :
I ended up setting up a reverse proxy in my local system running Apache (XAMPP Setup) to resolve a challenge in one of the system in my local network.
I have couple of application running in 192.168.1.5:3689. Currently these app doesn’t support CORS. I need to bring in a reverse proxy and add the CORS headers and forward the request from my local to the actual server.
Here the configuration i have used in the httpd-vhosts.conf file which is available in the apache installation directory. C:\xampp\apache\conf\extra\httpd-vhosts.conf
Allow from all
ProxyPass / http://192.168.1.5:3689/
ProxyPassReverse / http://192.168.1.5:3689/
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET
Even though my base Apache is running on 8010, i can add multiple virtual proxy hosts and ask apache to listen for client requests.
Note : You need to enable the proxy_http module in apache for this to work properly. Uncomment the line like the following
LoadModule proxy_http_module modules/mod_proxy_http.so
Hope this helps not just for CORS but whenever you are looking for redirecting requests from client to a different processing server.
Thanks for reading.