Friday, April 25, 2008

Using Apache to forward request

I am getting complaints from users that the mail server is not accessible from outside the local network due to the port number being block at other networks. My mail server is using port 8383 for webmail. Following steps allow my webmail to be accessed without needing to change the mail server settings.

The Plan
I need to setup an apache 2 on Linux and later reroute the DNS to use this new sever. All this using mod proxy in Apache.

What is mod proxy? see Apache site
"A typical usage of a forward proxy is to provide Internet access to internal clients that are otherwise restricted by a firewall. "

In this example my mail server details:
servername: mail.myserver.com.my
serverip: 192.93.20.3

STEP 1: Setting up the mod proxy on 192.93.20.4
My proxy is on CentOS 5.1 with Apache 2 (httpd-2.2.3-11.el5_1.centos.3)
  1. Install a Linux with Apache 2 and open the httpd.conf file

    vi /etc/httpd/conf/httpd.conf

  2. Make sure you have the following LoadModule lines (it waas there)
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so

Go to section three of the file and add

ServerName mail2.myserver.com.my
ProxyPass / http://firewall.myserver.com.my/
ProxyPassReverse / http://firewall.myserver.com.my/
RewriteEngine On
RewriteRule ^/$ http://mail.myserver.com.my:8383/ [P]



STEP 2: Redirect DNS
  1. Configure the DNS to accept mail2.myserver.com at the new server 192.93.20.4 which defaults to port 80
-

No comments:

Blog Archive