Looking at the awesome activity lately on my blog:
So here it is.
Wishing whoever reads this a better time ahead, as you replace those old calendars. And continue doing what you do best.
What is CGIProxy?
It is slightly ancient today, but CGIProxy still appears to be one of the good web proxies (non-transparent, CGI-based proxy script) out there.
Also, being essentially a PERL script, its easy to set it up with an existing Apache2 install. Thankfully enough, Mac comes with its own Apache2 server well integrated and the work required to edit and configure it to run PERL scripts is trivial.
Some reasons why you might want to run CGIProxy locally would be to test a local website for how it handles session data, or to even use it generally to filter content over your network, etc.. I had the former need while working with Hadoop‘s web applications as part of what I do on a daily basis at Cloudera.
Here’s how to setup CGIProxy locally on your Mac OSX (or earlier/later):
Setup Apache2 to allow Perl and CGI execution
Over Applications – System Preferences – Sharing, disable ‘Web Sharing’ if it is running. This stops the Apache2 web server that may already be running.
With that out of the door, we should be able to edit out our Apache2 configs without any issue. With your favorite text editor, I use vim below, edit the file /etc/apache2/httpd.conf and append the following lines to it somewhere along the end:
AddHandler cgi-script .cgi
This would let Apache be able to interpret files ending with .pl as CGI-scripts.
The next steps is to configure and allow execution of such files via your user account, which we can do by editing yet another file named /etc/apache2/users/<Your username>.conf. For instance, on my setup, the file is called /etc/apache2/users/harsh.conf. Modify the ‘Options’ configuration to allow CGI Execution:
Options Indexes MultiViews ExecCGI
With that done as well, we’re now ready to setup CGIProxy.
Setting up CGIProxy
Fetch the CGIProxy tarball, which is about 170 KB strong. Extracting this would provide you a script called nph-proxy.cgi. Place it in the ~/Sites directory of your Home.
We’re done with installing CGIProxy.
Now that we’re all set, we’ll just launch the Apache2 web server again and get to using the CGIProxy.
Head back to Applications – System Preferences – Sharing and enable ‘Web Sharing’ to run the server. Once up, you’ll get the public links to your homepage.
Head to <Your URL>/nph-proxy.cgi (For example, http://localhost/~harsh/nph-proxy.cgi) and you should see a properly functional, local CGIProxy ready for consumption. Hit it with a URL of choice and set some options you want it to use, and you’re off. Also look into the script with a text editor to see further configuration options.
If you were trying to boot up and install (netinstall) ArchLinux under VMWare Fusion, you might run into network problems at the installation stage since the base setup doesn’t seem to configure the DHCP right.
The fix is to do the following to setup the DHCP config manually:
- Append these contents at the end: https://gist.github.com/949987
- Done! You should have proper network connectivity now.
Notes notes notes. Moar Notes!