• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to Configure Reverse Proxy with Apache in CentOS

1082

To Configure Reverse Proxy with Apache in CentOS

Reverse proxy is a proxy server used to redirects the HTTP connection that request from client to more than one backend webservers. It provides a security and increase performance for web servers. This article shows the configuration process of Reverse Proxy with Apache in CentOS.

Testing Environment

Apache Reverse Proxy:

IP Address &ndash 192.168.5.237
Hostname &ndash node1.example.com

Apache Backend:

IP Address &ndash 192.168.5.238
Hostname &ndash node2.example.com

Pre-requisties

Fully Qualified Domain Name (FQDN) is required for all the servers.
Create the entry in /etc/hosts file for hostname resolution between reverse proxy and Apache backend.


Entry:

192.168.5.237 node1.example.com node1
192.168.5.238 node2.example.com node2

Configuration of Reverse Proxy with Apache

Before configuration process, install the Apache on backend node (node 2).

[root@node2 ~]# yum install httpd -y
Loaded plugins: fastestmirror, langpacks
base                                                                                                                                                         | 3.6 kB  00:00:02     
extras                                                                                                                                                       | 3.4 kB  00:00:00     
updates                                                                                                                                                      | 3.4 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirror.fibergrid.in
 * extras: mirror.fibergrid.in
 * updates: mirror.fibergrid.in
Resolving Dependencies
-->  Running transaction check
--->  Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed
.
.
.
Installed:
  httpd.x86_64 0:2.4.6-40.el7.centos.4                                                                                                                                              

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7             apr-util.x86_64 0:1.5.2-6.el7             httpd-tools.x86_64 0:2.4.6-40.el7.centos.4             mailcap.noarch 0:2.1.41-2.el7            

Complete!

Start and enable the HTTPD service with the following command.

[root@node2 ~]# systemctl start httpd
[root@node2 ~]# systemctl enable httpd
ln -s ' /usr/lib/systemd/system/httpd.service'  ' /etc/systemd/system/multi-user.target.wants/httpd.service' 

Once the Apache gets enabled, add the firewall rule for outside connections.

[root@node2 ~]# firewall-cmd --permanent --add-service=http
success
[root@node2 ~]# firewall-cmd --reload
Success

Place sample webpage index.html file on document root /var/www/html.

[root@node2 ~]# cd /var/www/html
[root@node2 html]# vim index.html

Entry:

Hi welcome to linuxhelp.com

Now its time to configure reverse proxy on node1 machine. Install the httpd package with the following command.

[root@node1 ~]# yum install httpd -y
Loaded plugins: fastestmirror, langpacks
base                                                                                                                                                         | 3.6 kB  00:00:00     
extras                                                                                                                                                       | 3.4 kB  00:00:00     
updates                                                                                                                                                      | 3.4 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirror.fibergrid.in
 * extras: mirror.fibergrid.in
 * updates: mirror.fibergrid.in
Resolving Dependencies
-->  Running transaction check
--->  Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed
.
.
.
talled:
  httpd.x86_64 0:2.4.6-40.el7.centos.4                                                                                                                                              

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7             apr-util.x86_64 0:1.5.2-6.el7             httpd-tools.x86_64 0:2.4.6-40.el7.centos.4             mailcap.noarch 0:2.1.41-2.el7            

Complete!

Immediately enable the Mod_proxy module in Apache as follows,

[root@node1 ~]# 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

Add the following lines to the reverse.conf file as follows,

[root@node1 ~]#  vim /etc/httpd/conf.d/reverse.conf
Apache Reverse Proxy
< IfModule mod_proxy.c> 
          ProxyRequests Off
          < Proxy *> 
                    Require all granted
          < /Proxy> 
           ProxyPass  / http://node2.example.com/
           ProxyPassReverse  / http://node2.example.com/
< /IfModule> 


Utilize the following command to start and enable httpd service.

[root@node1 ~]# systemctl restart httpd
[root@node1 ~]# systemctl enable httpd
ln -s ' /usr/lib/systemd/system/httpd.service'  ' /etc/systemd/system/multi-user.target.wants/httpd.service' 

Again add the firewall rule for outside connections.

[root@node1 ~]# firewall-cmd --permanent &ndash add-service=http
success
[root@node1 ~]# firewall-cmd --reload

Once the above process is completed, open the browser with the IP address for reverse proxy. Now you can view the sample file content as output.

1

Tags:
jackson
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What is the difference between Proxy and Reverse Proxy?

A

A reverse proxy server is a type of proxy server that typically sits behind the firewall in a private network and directs client requests to the appropriate backend server. A reverse proxy pr

Q

How to setup a Reverse Proxy with Apache Mod_Proxy?

A

For setting reverse proxy in Apache
# a2enmod proxy_http
# Service apache2 restart

Q

Is Load Balancer a reverse proxy?

A

Reverse proxy servers and load balancers are components in a client-server computing architecture. A reverse proxy accepts a request from a client, forwards it to a server that can fulfill it, and returns the server's response to the client.

Q

Why would you use a reverse proxy?

A

A typical usage of a reverse proxy is to provide Internet users access to a server that is behind a firewall. Reverse proxies can also be used to balance the load among several back-end servers or to provide caching for a slower back-end server.

Q

What is Apache proxy?

A

Apache httpd can also act as a reverse proxy server, also-known-as a "gateway" server.

Related Tutorials in How to Configure Reverse Proxy with Apache in CentOS

Related Tutorials in How to Configure Reverse Proxy with Apache in CentOS

How To Install AnyDesk on Centos 7
How To Install AnyDesk on Centos 7
Apr 2, 2018
How to install Tiki Wiki CMS Groupware on CentOS 7
How to install Tiki Wiki CMS Groupware on CentOS 7
May 31, 2018
How to install PHP ImageMagick on CentOS 7
How to install PHP ImageMagick on CentOS 7
Nov 4, 2017
How to Upgrade and Downgrade the PHP Versions on CentOS 7.6
How to Upgrade and Downgrade the PHP Versions on CentOS 7.6
Jun 4, 2019
How to install Apache from Source Code on CentOS 7
How to install Apache from Source Code on CentOS 7
Oct 21, 2017
How to enable or disable repositories in CentOS
How to enable or disable repositories in CentOS
Mar 28, 2018
How to install AWStats on CentOS 7
How to install AWStats on CentOS 7
Dec 8, 2017
How to install Apache JMeter in CentOS 7
How to install Apache JMeter in CentOS 7
Mar 24, 2017

Related Forums in How to Configure Reverse Proxy with Apache in CentOS

Related Forums in How to Configure Reverse Proxy with Apache in CentOS

CentOS
connor class=
How To Completely Remove Apache package On CentOS 7.6
May 14, 2019
CentOS
ceriaimmaculate class=
setfacl : command not found
Jan 3, 2018
CentOS
mason class=
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Nov 20, 2018
CentOS
landon class=
Command to find SNMP Version
May 28, 2018
CentOS
arjitharon class=
cannot start minio service help
Mar 10, 2018
Apache
isaac class=
How to disable apache welcome page on Ubuntu
Dec 15, 2018
Apache tomcat
AadrikaAnshu class=
Cannot find ./catalina.sh The file is absent or does not have execute permission This file is needed to run this program
Jun 17, 2019
gitlab
caden class=
Insufficient space in download directory /var/cache/yum/x86_64/6/base/packages
Jul 22, 2019

Related News in How to Configure Reverse Proxy with Apache in CentOS

Related News in How to Configure Reverse Proxy with Apache in CentOS

Attackers take advantage of Apache Struts vulnerabilities
Attackers take advantage of Apache Struts vulnerabilities
Mar 17, 2017
An Apache Web Server Bug That Grants Root Access on  Shared Web Hosts
An Apache Web Server Bug That Grants Root Access on Shared Web Hosts
Apr 10, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Jayce ?
What are the types of table used in IPtables

What are the various types of table used in IPtables and how to use that for my server security?

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.