Proxy server to handle multiple sub-domains with http and https protocol
1. Edit host in proxy server (10.12.1.100)
vi /etc/host and add the following sub-domains and IPs
10.12.1.110 site1.myserver.com
10.12.1.111 site2.myserver.com
10.12.1.112 site3.myserver.com
2. Create a foo.conf file in the conf.d of your apache directory with following content.
NameVirtualHost *: 80
NameVirtualHost *: 443
# Proxy for http in site1.myserver.com
ServerName site1.myserver.com
ProxyPreserveHost on
ProxyPass / http://site1.myserver.com/
ProxyPassReverse / http://site1.myserver.com/
# Proxy for https in site1.myserver.com
ServerName site1.myserver.com
SSLEngine on
SSLProxyEngine on
# Proxy for https in site1.myserver.com
SSLEngine on
SSLProxyEngine on
# ca.crt and ca.key generated in site1.myserver.com and copied to proxy server.
# In my case, i've stored it in /etc/pki/tls/site1/
SSlCertificateFile /etc/pki/tls/site1/ca.crt SSlCertificateKeyFile /etc/pki/tls/site1/ca.key
ProxyPreserveHost on
ProxyPass / https://site1.myserver.com /
ProxyPassReverse / https://site1.myserver.com/
# Proxy for http in site2.myserver.com
ServerName site2.myserver.com
ProxyPreserveHost on
ProxyPass / http://site2.myserver.com/
ProxyPassReverse / http://site2.myserver.com/
# Proxy for https in site2.myserver.comSSLEngine on
SSLProxyEngine on
# ca.crt and ca.key generated in site2.myserver.com and copied to proxy server.
# In my case, i've stored it in /etc/pki/tls/site2/
SSlCertificateFile /etc/pki/tls/site2/ca.crt
SSlCertificateKeyFile /etc/pki/tls/site2/ca.key
ProxyPreserveHost on
ProxyPass / https://site2.myserver.com/
ProxyPassReverse / https://site2.myserver.com/
# Proxy for http in site3.myserver.com
ServerName site3.myserver.com
ProxyPreserveHost on
ProxyPass / http://site3.myserver.com/
ProxyPassReverse / http://site3.myserver.com/
ServerName site3.myserver.com
SSLEngine on
SSLProxyEngine on
# Proxy for https in site3.myserver.com
SSLEngine on
SSLProxyEngine on
# ca.crt and ca.key generated in site3.myserver.com and copied to proxy server.
# In my case, i've stored it in /etc/pki/tls/site3/
SSlCertificateFile /etc/pki/tls/site3/ca.crt
SSlCertificateKeyFile /etc/pki/tls/site3/ca.key
ProxyPreserveHost on
ProxyPass / https://site3.myserver.com/
ProxyPassReverse / https://site3.myserver.com/
3. Restart apache service and test the URL on your browser.
Home

