How to use Apache Reverse Proxy Server to service to multiple web server?

Issues related to configuring your network
Post Reply
hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

How to use Apache Reverse Proxy Server to service to multiple web server?

Post by hack3rcon » 2021/03/17 11:18:43

Hello,
I installed and configure an Apache Web Server as a Reverse Proxy on CentOS 8. I created a Virtual Host file (reverse_proxy.conf) under the "/etc/httpd/conf.d" directory with below content:

Code: Select all

<VirtualHost *:80>
        ProxyPreserveHost On
        ProxyPass / http://192.168.1.20/
        ProxyPassReverse / http://192.168.1.20/
</VirtualHost>
It's worked.
I want this Reverse Proxy Server service to more than websites:

Code: Select all

The Internet ---> Apache Reverse Proxy ---> Web Server 1
                                       ---> Web Server 2
I have a question. For each website I need a Virtual Host config file or I can put all websites configuration in one virtual Host file?

I created another Virtual Host config file for other websites:

The content of reverse_proxy1.conf file is:

Code: Select all

<VirtualHost *:80>
        ServerName Website1
        ProxyPreserveHost On
        ProxyPass / http://192.168.1.20/
        ProxyPassReverse / http://192.168.1.20/
</VirtualHost>
The content of reverse_proxy2.conf file is:

Code: Select all

<VirtualHost *:80>
        ServerName Website2   
        ProxyPreserveHost On
        ProxyPass / http://192.168.1.4/
        ProxyPassReverse / http://192.168.1.4/
</VirtualHost>
But when I browse my Reverse Proxy Server then it can't handle the requests and show me below error:
Service Unavailable
I checked log file and it show me:
# cat /var/log/httpd/error_log
[Wed Mar 17 01:12:44.817647 2021] [proxy:error] [pid 28599:tid 28649] (113)No route to host: AH00957: HTTP: attempt to connect to 192.168.1.20:80 (192.168.1.20) failed
[Wed Mar 17 01:12:44.817775 2021] [proxy_http:error] [pid 28599:tid 28649] [client 10.0.3.2:52142] AH01114: HTTP: failed to make connection to backend: 192.168.1.20
Why it just see "reverse_proxy1.conf" file?

Thank you.

Post Reply