Configure Apache Reverse Proxy on Mac

Following up on the previous posts on configuring apache on Ubuntu, I now post the method to do the same on the Mac.

Step 1: You will need to download the mod_proxy_html module from http://apache.webthing.com/mod_proxy_html/

Step 2: Compile the code.

$ sudo apxs -ci -I /usr/include/libxml2 mod_xml2enc.c
$ sudo apxs -ci -I /usr/include/libxml2 -I . mod_proxy_html.c

Then update you httpd.conf to include

LoadFile /usr/lib/libxml2.dylib
LoadModule  proxy_html_module   libexec/apache2/mod_proxy_html.so
LoadModule  xml2enc_module   libexec/apache2/mod_xml2enc.so

Also take a look at the proxy-httpd.conf file that ships with mod_proxy_html for additional config you may want.

Filed under  //   Apache2   Apple OS X   Technology   mac  

Apache2 reverse proxy with SSL

Following up on the last post, here I am outlining how to make reverse
proxy work with SSL,

$ sudo a2enmod ssl*

to enable all Apache SSL modules.
After this I appended the following code in the file
/etc/apache2/sites-available/default-ssl
 
 AddDefaultCharset off 
 Order deny,allow 
 Allow from all 
 
SSLProxyEngine on 
SSLProxyCACertificateFile /etc/apache2/cacerts.crt 
ProxyPass /abc https://xxx.xxx.xx.xx:4400/abc 
ProxyPassReverse /abc https://xxx.xxx.xx.xx:4400/abc 
ProxyVia off

Since I was re-directing to a secure server, I faced two errors:
[error] [client xxx.xxx.xx.xx] SSL Proxy requested for 
127.0.1.1:443 but not enabled [Hint: SSLProxyEngine] 
[error] proxy: HTTPS: failed to enable ssl support for 
xxx.xxx.xx.xx:4400 (xxx.xxx.xx.xx)

The main reasons being, first I had forgotten to add the
SSLProxyEngine parameter to the configuration.
Secondly, when apache acts as a proxy, it acts like a client
requesting over SSL. Hence it needs the server certificate (PEM
encoded) to do a successful handshake.
Using openSSL,
openssl s_client -connect xxx.xxx.xx.xx:4400 -showcerts

Copied the encoded content from -----BEGIN CERTIFICATE----- & -----END
CERTIFICATE----- , saved it to cacerts.crt.
After this apache started serving SSL access to remote server via proxy.

Filed under  //   Apache2   Technology   ubuntu 11.04  

Apache reverse proxy using mod_proxy

In the current project, we are using GWT on the front end and Django
on the back-end. To avoid SOP (Same Origin Policy) related issues, the
GWT code and the Django code has to be served from the same server. To
work around this problem, we setup a local (development machine)
Apache server, with reverse proxy.

http://localhost/abc was mapped to http://remote_aws_ip:8888/abc

To do this, follow the steps below:

 
$ sudo apt-get install libapache2-mod-proxy-html 
$ sudo a2enmod proxy* 
 

Create a new file, remote_aws_ip, inside /etc/apache2/sites-available

 
<VirtualHost 127.0.0.1:80> 
 DocumentRoot "/var/www" 
 ServerName remote_aws_ip 
 <Proxy *> 
 AddDefaultCharset off 
 Order deny,allow 
 Allow from all 
 </Proxy> 
 
 ProxyPass /abc http://remote_aws_ip:8888/hcm 
 ProxyPassReverse /abc http://remote_aws_ip:8888.com/hcm 
 ProxyVia off 
</VirtualHost> 

Then enable the site, by running

$ sudo a2ensite remote_aws_ip 

This will make a symlink to the file into sites-enabled.

Last but not the least

$ sudo service apache2 restart

Now I point my browser to http://localhost/abc and it fetches content
from http://remote_aws_ip:8888/abc

Filed under  //   Apache2   Technology   ubuntu 11.04  

About

A software professional & an amateur wildlife photographer

Tumblr