Jan 17, 2012

Reverse Proxy in apache

Reverse Proxy Configuration in apache

Introduction:

            A reverse proxy is a gateway for servers, it can be used whenever multiple web servers must be accessible via a single public IP address. The web servers listen on different ports in the same machine, with the same local IP address or, possibly, on different machines and different local IP addresses altogether. The reverse proxy analyses each incoming call and delivers it to the right server within the local area network.

Release:
RedHat Enterprise Linux
Apache 2.x

Problem:
Configure Apache webserver as a reverse proxy server

Solution:

1)       Install the required rpm

            # yum install httpd

2)       Enable the proxy related modules in the httpd,conf file

            # vi /etc/httpd/conf/httpd.conf

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


3)       Add the below entries to the http configuration file.

                        # vi /etc/httpd/conf/httpd.conf

            <IfModule mod_proxy.c>

            ProxyRequests Off
            <Proxy *>
            Order deny,allow
            Allow from all
            </Proxy>

            ProxyPreserveHost On
            ProxyVia On
            SSLProxyEngine on

            ProxyPass /webdav http://ServerIP:8080/webdav 
            ProxyPassReverse /webdav http://ServerIP:8080/webdav
 
            </IfModule>

Note: In the above sample all the request comes to /webdav URL redirect to the another tomcat server. For example Apache server IP is 10.0.0.1 and the tomcat server IP is 10.0.0.2, then the request like http://10.0.0.2/webdav will be redirect to http://10.0.0.2:8080/webdav

4)       To enable logging for the reverse proxy, add the below lines in the configuration file

            # vi /etc/httpd/conf/httpd.conf

            <IfModule mod_proxy.c>

            CustomLog logs/access_proxy.log combined
            ErrorLog logs/error_proxy.log

            </IfModule>

5)       Restart the httpd service

                        # /etc/init.d/httpd restart

                       



Jan 5, 2012

webdav configuration in apache


Sample Webdav Configuration in Apache

Introduction:
            WebDAV stands for "Web-based Distributed Authoring and Versioning". It is a set of extensions to the HTTP protocol which allows users to collaboratively edit and manage files on remote web servers.

Release:
RedHat Enterprise Linux 5.x
Apache 2.x

Problem:
Need to enable the webdav (Web-based Distributed Authoring and Versioning) in apache web server.

Solution:

1)      Install the required rpms

                        # yum install httpd

2)      Enable the webdav related modules in the httpd,conf file

            # vi /etc/httpd/conf/httpd.conf

            LoadModule dav_module modules/mod_dav.so
            LoadModule dav_fs_module modules/mod_dav_fs.so

3)      Create a directory to publish over web server

                  # mkdir /var/www/webdav

4)      Create one new configuration file for the webdav

            # vi /etc/httpd/conf.d/webdav.conf

            <IfModule mod_dav.c>
            LimitXMLRequestBody 131072

            Alias /webdav "/var/www/webdav"
            <Directory /var/www/webdav>
            Dav On
            Options +Indexes
            IndexOptions FancyIndexing
            AddDefaultCharset UTF-8
            Order allow,deny
            Allow from all
            </Directory>
            </IfModule>

5)      If want to enable authentication for the webdav means, add the below lines in the webdav.conf file and also create the user database
           
            # vi /etc/httpd/conf.d/webdav.conf

            AuthType Basic
            AuthName "WebDAV Server"
            AuthUserFile /etc/httpd/webdav.users.db
            Require valid-user
           
6)      Create the user database using the below command

            # htpasswd -c /etc/httpd/webdav.users.db testuser

7)      Restart the httpd service

            # service httpd restart

8)      Access the webdav from the client using the below URL

            http://ServerIPAddress/webdav