I was am planning to deploy Reverse proxy using Apache, but before i do it on Prod env i tried to implement in my home lab.I have two vms running on Redhat.
192.168.56.70 mainsite.example.com mainsite
#192.168.56.70 mainsite2.example.com mainsite2
192.168.56.71 areverseproxy.example.com areverseproxy
on Backend Apache server i made a virtuial host, contents of that VHost
<VirtualHost *:80>
# DocumentRoot "/var/www/html/"
# <Directory "/var/www/html/mainsite">
# AllowOverride None
# # Allow open access:
# Require all granted
# </Directory>
#DirectoryIndex "/var/www/html/mainsite/index.html"
ServerName mainsite.example.com
ServerAlias mainsite
Redirect permanent / https://192.168.56.70
ErrorLog "/var/log/httpd/mainsite.example.com-error_log"
CustomLog "/var/log/httpd/mainsite.example.com-access_log" common
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
DocumentRoot "/var/www/html/mainsite"
<Directory "/var/www/html/mainsite">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
#DirectoryIndex "/var/www/html/mainsite/index.html"
ServerName mainsite.example.com
ServerAlias mainsite
ErrorLog "/var/log/httpd/mainsite.example.com-error_log"
CustomLog "/var/log/httpd/mainsite.example.com-access_log" common
</VirtualHost>
And on Reverse Proxy Server i added these lines to enable Reverse proxy
<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
Require all granted
</Proxy>
# backend server and forwarded path
ProxyPreserveHost On
ProxyPass / http://mainsite.example.com/
ProxyPassReverse / http://mainsite.example.com/
</IfModule>
If i try to open URL http://192.168.56.71 it will redirect to https://192.168.56.70 which is ok if i dont have Reverse proxy server but in reverse proxy scenario it should be https://192.168.56.71
Can any one guide what changes i have to made on Reverse Proxy server so the URl remains https://192.168.56.71 if i type URL http://192.168.56.71
Thanks a lot
After deploying on Prod Server
Error
[Mon May 31 09:16:26.650015 2021] [proxy_http:error] [pid 104179] (103)Software caused connection abort: [client 192.168.22.140:40286] AH01102: error reading status line from remote server 172.16.1.140:443
[Mon May 31 09:16:26.650214 2021] [proxy:error] [pid 104179] [client 192.168.22.140:40286] AH00898: Error reading from remote server returned by /