Home > Cpanel/WHM, HA, Linux application Installations > Apache proxy redirect

Apache proxy redirect

SITUATION: Customer has a single website with four different web applications installed under four sub directories of the website. Now configure apache to serve all these four applications from four different ports.

ASSUMPTIONS:

1) OS – Ubuntu 11

2) Website name and documentroot,

Name: jackal777.com

DocumentRoot:  /home/jackal/public_html

3) Web application sub-directories and the ports going to be used,

/home/jackal/public_html/app1 : Port 7001
/home/jackal/public_html/app2 : Port 7002
/home/jackal/public_html/app3 : Port 7003
/home/jackal/public_html/app4 : Port 7004

4) Apache mod_proxy module is installed. You can install it using,

apt-get install libapache2-mod-proxy-html -y

SOLUTION:

1) Open up /etc/apache2/ports.conf and add the following directives,

Listen 80
Listen 127.0.0.1:7001
Listen 127.0.0.1:7002
Listen 127.0.0.1:7003
Listen 127.0.0.1:7004

2) Enable mod_proxy by copying the configuratons from ‘mods-available’ directory to ‘mods-enabled’

cp -pr /etc/apache2/mods-available/*proxy* /etc/apache2/mods-enabled/

3) Create a virtualhost file “/etc/apache2/sites-enabled/jackal777.com” for website with the following contents,

<VirtualHost *:80>
ServerName jackal777.com
DocumentRoot /home/jackal/public_html

ProxyPass /app1/ http://127.0.0.1:7001/
ProxyPass /app2/ http://127.0.0.1:7002/
ProxyPass /app3/ http://127.0.0.1:7003/
ProxyPass /app4/ http://127.0.0.1:7004/

</VirtualHost>

<VirtualHost 127.0.0.1:7001>
DocumentRoot /home/jackal/public_html/app1
</VirtualHost>

<VirtualHost 127.0.0.1:7002>
DocumentRoot /home/jackal/public_html/app2
</VirtualHost>

<VirtualHost 127.0.0.1:7003>
DocumentRoot /home/jackal/public_html/app3
</VirtualHost>

<VirtualHost 127.0.0.1:7004>
DocumentRoot /home/jackal/public_html/app4
</VirtualHost>

4) Test configuration and gracefully restart apache.

apache2ctl -t
apache2ctl -k graceful

5) Now access the url’s,

http://jackal777.com/app1/

http://jackal777.com/app2/


http://jackal777.com/app3/


http://jackal777.com/app4/

 

SCOPE: Using mod_proxy, we could forward requests coming to different servers and make the applications running from several different servers.

 

Hope this info will be somewhat useful :)

About these ads
  1. September 14, 2013 at 4:14 am

    Perfect :)

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 27 other followers

%d bloggers like this: