Archive

Archive for May, 2013

Setting up Apache as Forward proxy

My usecase:

I have to talk to a third party server(thirdparty.server.com) , which is accessible only via allowed.server.com. And, my.server.com has access to allowed.server.com.

This calls for Apache forward proxy on allowed.server.com.

These steps pertain to httpd 2.4.4
1. Download Httpd
2. Go to bin folder

./configure --prefix=<FOLDER_TO_INSTALL> --enable-mods-shared="proxy proxy_http proxy_ftp proxy_connect"

The enable-mods-shard option will install the modules needed for setting up a forward proxy. Also refer to this if you need to modify your apache installation (rather than recompiling again) 
how-to-install-mod_proxy-module-into-apache-788406/
I ran into these errors while configuring

configure: error: APR not found. Please read the documentation.

download the latest versions of both APR and APR-Util from Apache APR, unpack them into ./srclib/apr and ./srclib/apr-util (be sure the domain names do not have version numbers; for example, the APR distribution must be under ./srclib/apr/). Reference: http://stackoverflow.com/questions/9436860/apache-httpd-setup-and-installation

./configure --with-included-apr

Then the pcre errors

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

Download PCRE from PCRE.org

Compile it with a prefix and install it:

./configure --prefix=/usr/local/pcre
make
make install

Go back to where your Apache installation is and compile Apache with PCRE:

--with-pcre=/usr/local/pcre

Once configure is successful, do make and ‘make install’.

Got to conf/httpd.conf

Uncomment these lines


LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Change your port if needed

Listen 9999

Set the forward proxy

<IfModule mod_proxy.c>
 ProxyRequests On
 ProxyVia On
 <Proxy *>
 Order deny,allow
 Allow from all
 </Proxy>
 ProxyPass /test http://www.google.com/
</IfModule>

And now, when you do http://my.server.com/test -> it will redirect to http://www.google.com