Thursday 20 August 2015

APACHE AS REVERSE PROXY

Apache as Reverse Proxy
 Requirement:
(1) Web Server
(2) Proxy Server
(3) DNS SERVER
(4) CLIENT

WEB SERVER IP:                                192.168.1.3
WEB SERVER HOSTNAME:            google.com

PROXY SERVER IP                             192.168.1.5
PROXY SERVER HOSTNAME         proxy.server.com

DNS SERVER IP:                                 192.168.1.4
DNS SERVER  HOSTNAME:            masterdns.arun.com 

CLIENT IP:                                            192.168.1.1

Client Server Architecture 

                                                                                                                                                           
 



(A) Web Server:

Hostname:  google.com
IP Address:  192.168.1.3
(1)    Install  apache packages
[root@google ~]# yum install httpd*

(2)    Make Changes in below configuration  file.
[root@google ~]# vim /etc/httpd/conf/httpd.conf

(2.1)
#Listen 12.34.56.78:80
Listen 80
Listen 81
(2.2)
NameVirtualHost 192.168.1.3:80
<VirtualHost 192.168.1.3:80>
        ServerAdmin root@mail.google.com
        DocumentRoot /var/www/html
        DirectoryIndex chat.html
        ServerName chat.google.com
</VirtualHost>
NameVirtualHost 192.168.1.3:81
<VirtualHost 192.168.1.3:81>
        ServerAdmin root@mail.google.com
        DocumentRoot /var/www/html
        DirectoryIndex mail.html
        ServerName mail.google.com
</VirtualHost>

(3)    Create 2 html file in /var/www/html  directory
[root@google ~]# cd /var/www/html/
[root@google html]# ll
total 8
-rwxrwxrwx 1 root root 53 Aug 11 16:35 chat.html
-rwxrwxrwx 1 root root 36 Aug 11 16:35 mail.html
[root@google html]#

[root@google html]# cat chat.html
Welcome to GooGle Chating Services.Enjoy The Chating

[root@google html]# cat mail.html
Welocome to GooGle Mailing Service.

(4)    Restart the apache service
[root@google html]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]




(B)  Proxy Server
Hostname:  proxy.server.com
IP Address: 192.168.1.5
(1)    Install apache packages
[root@proxy ~]# yum install httpd*
(2)    Make Changes in below configuration  file.
[root@proxy ~]# vim /etc/httpd/conf/httpd.conf
(2.1)
#Listen 12.34.56.78:80
Listen 80
Listen 81
(2.2)
NameVirtualHost 192.168.1.5:80
<VirtualHost 192.168.1.5:80>
        ServerAdmin root@proxy.server.com
        DocumentRoot /var/www/html
        DirectoryIndex chat.html
        ServerName proxy.server.com
</VirtualHost>

<IfModule mod_proxy.c>
ProxyRequests Off

ProxyPass /chat.html http://chat.google.com/chat.html
ProxyPassReverse /chat.html http://chat.google.com/chat.html

NameVirtualHost 192.168.1.5:81
<VirtualHost 192.168.1.5:81>
        ServerAdmin proxy.server.com
        DocumentRoot /var/www/html
        DirectoryIndex mail.html
        ServerName proxy.server.com
</VirtualHost>


<IfModule mod_proxy.c>
ProxyRequests Off

ProxyPass /mail.html  http://mail.google.com/mail.html
ProxyPassReverse /mail.html  http://mail.google.com/mail.html

(3)    Create 2 html file in /var/www/html  directory
[root@proxy html]# cd /var/www/html/
[root@proxy html]# ll
total 8
-rwxrwxrwx. 1 root root 14 Aug 19 12:01 chat.html
-rwxrwxrwx. 1 root root 14 Aug 19 12:01 mail.html
[root@proxy html]#         


[root@proxy html]# cat chat.html
proxy chating

[root@proxy html]# cat mail.html
proxy mailing
[root@proxy html]#

(4)    Restart the apache service
[root@proxy html]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

[root@proxy html]#


(C) DNS SERVER:
Please refer DNS blog for DNS server configuration

(1)    Now We have to make entry of google.com  and server.com zones in  /etc/named.conf  file
[root@masterdns named]# vim /etc/named.conf





























(2)    Make changes in forward and reverse zone file
[root@masterdns named]# cd /var/named/
[root@masterdns named]# cat for
$TTL 86400  
@       IN SOA  masterdns.arun.com. root.arun.com. (
                                1      ; serial
                                        3600    ; refresh
                                        1800    ; retry
                                        604800  ; expire
                                        86400   ; minimum
               
)
@               IN      NS      masterdns.arun.com.
@               IN      NS      slavedns.arun.com.
@                            IN           NS          mail.google.com.
@                            IN           NS          chat.google.com.
@                            IN           NS          proxy.server.com.

masterdns       IN      A       192.168.1.4
slavedns        IN      A       192.168.1.2
www                     IN           A             192.168.1.4
mail                        IN           A             192.168.1.3
chat                       IN           A             192.168.1.3
proxy                    IN           A             192.168.1.5
[root@masterdns named]#
[root@masterdns named]# cat rev
$TTL  864000
@       IN SOA  masterdns.arun.com. root.arun.com. (
                                1    ; serial
                                        3600    ; refresh
                                        1800    ; retry
                                        604800  ; expire
                                        86400   ; minimum
)


@               IN      NS      masterdns.arun.com.
@               IN      NS      slavedns.arun.com.
@                            IN           NS          proxy.server.com.
@               IN      PTR     arun.com.
@                            IN           PTR        google.com.
@                            IN           PTR        server.com.       

masterdns       IN      A       192.168.1.4
slavedns        IN      A       192.168.1.2
www                     IN           A             192.168.1.4
mail                        IN           A             192.168.1.3
chat                       IN           A             192.168.1.3
proxy                    IN           A             192.168.1.5

4             IN      PTR     masterdns.arun.com.
2             IN      PTR     slavedns.arun.com.
4                              IN           PTR        www.arun.com.
3                              IN           PTR        mail.google.com.
3                              IN           PTR        chat.google.com.
5                              IN           PTR        proxy.server.com.

(3)    Restart Named  Services
[root@masterdns named]# /etc/init.d/named restart
Stopping named: .                                          [  OK  ]
Starting named:                                            [  OK  ]
[root@masterdns named]#




(D)  Client :
IP Address: 192.168.1.1































(2)Now if we Access Proxy server then Proxy Server Redirect Request to Web server and we get web pages of Web Server.

(2.1) From IP

















(2.2) From Name

















No comments:

Post a Comment