How to Setup Reverse Proxy Server for Apache Web Server on CentOS 7.6
Reverse Proxy server Setup for Apache Web server On CentOS 7.6
Reverse Proxy Server:
The reverse proxy server is a type of proxy server that sits behind the firewall in a private network. The reverse proxy has used the server such as a web server.
Setup:
Backend Host - Apache web server 192.168.7.229 www.linuxhelp1.com
Reverse proxy Host 192.168.7.227 www.linuxhelp2.com
you/Client ------> internet------->Reverse Proxy server <--------> Apache Web server or Backend
Backend Server – Apache Web server
Check the IP address of the Apache web server.
[root@linuxhelp ~]# ip a
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
link/ether 00:0c:29:f9:d6:3d brd ff:ff:ff:ff:ff:ff
inet 192.168.7.229/24 brd 192.168.7.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
Install the Apache Web server by executing the following command.
[root@linuxhelp ~]# yum install httpd -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.xeonbd.com
* extras: mirror.xeonbd.com
* updates: centos-hcm.viettelidc.com.vn
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
extras/7/x86_64/primary_db | 205 kB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-89.el7.centos will be installed
.
.
.
.
Installed:
httpd.x86_64 0:2.4.6-89.el7.centos
Dependency Installed:
apr.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-89.el7.centos
Complete!
Enable the service of Apache web server.
[root@linuxhelp ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Start the service of Apache server.
[root@linuxhelp ~]# systemctl start httpd
Check the status of the Apache Web server.
[root@linuxhelp ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-07-09 10:08:21 IST; 9s ago
Navigate to the Document root directory of Apache Web server.
[root@linuxhelp ~]# cd /var/www/html
Create a file named index.html and save the file with the following content.
[root@linuxhelp html]# vim index.html
Hello!
Welcome To LinuxHelp Channel
Have a Great day ahead,
Restart the service of Apache server.
[root@linuxhelp html]# systemctl restart httpd
With this,backend Setup of Apache web server comes to end
Reverse proxy Server Setup.
Verify the ip address of a reverse proxy server.
[root@linuxhelp ~]# ip a
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
link/ether 00:0c:29:f9:d6:3d brd ff:ff:ff:ff:ff:ff
inet 192.168.7.227/24 brd 192.168.7.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
Install the Apache web server as follows.
[root@localhost ~]# yum install httpd -y
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
* base: mirror.nbrc.ac.in
* extras: mirror.nbrc.ac.in
* updates: mirror.nbrc.ac.in
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/2): extras/7/x86_64/primary_db | 205 kB 00:00:01
(2/2): updates/7/x86_64/primary_db | 6.5 MB 00:00:14
Resolving Dependencies
--> Running transaction check
.
.
.
.
.
Installed:
httpd.x86_64 0:2.4.6-89.el7.centos
Dependency Installed:
apr.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-89.el7.centos mailcap.noarch 0:2.1.41-2.el7
Complete!
Enable the service of Apache web server.
[root@localhost ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Start the service of Apache web server.
[root@localhost ~]# systemctl start httpd
Verify the status of Apache web server.
[root@localhost ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-07-09 15:47:28 IST; 11s ago
Search for mod_proxy pattern in the below mentioned configuration file to check the modules enabled status.
[root@localhost ~]# grep "mod_proxy" /etc/httpd/conf.modules.d/00-proxy.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_express_module modules/mod_proxy_express.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
Navigate to Apache’s Customised Configuration file and Create a virtual host for reverse proxy server as follows.
[root@localhost ~]# vim /etc/httpd/conf.d/reverse.conf
#Apache Reverse Proxy
<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://www.linuxhelp1.com/
ProxyPassReverse / www.linuxhelp1.com/
</IfModule>
Restart the service of Apache server.
[root@localhost ~]# systemctl restart httpd
With this Reverse Proxy Setup comes to an end
Enter the reverse Proxy server IP address on the client machine which shows the content that has saved in the Document Root Directory of the Apache web server.
With this, setup of Reverse Proxy Server for Apache web server on CentOS 7.6 comes to end.
Comments ( 0 )
No comments available