Apache: How to use reverse secure proxy to chain secure apache servers – updated

By | December 3, 2016

On the site I host my services I have only one IP from the ISP and naturally a single 443 port to server https requests. If you have to host multiple sites behind that you can do it very easy with apache. You just have to define Virtual hosts for each different site.

Define a standard virtual host on the main site
In case of the blog the configuration looks like the following.

Define a redirect for http requests to blog.voina.org
In case any http requests I force https to the client by redirecting the traffic to https.

 

Define a secure virtual host for blog.voina.org
Notice the certificates and the select list of SSLChiperSuite. I am using certificates from a recognised certification authority and only the secure SSL ciphers.

 

The same way we can set up several other sites. On the same server I host also a owncloud instance under home.voina.org. I am going to skip that part of the configuration of the home.voina.org virtual host.
The next focus will be to show how we can chain requests from the main site to a second site.

Define a reverse proxy virtual host on the main site
The next site store.voina.org (a opencart instance) is going to be accessible through the main site but hosted on a second machine. The main site will act as a reverse proxy that hides the real machine where store.voina.org is actually hosted.

Define a redirect for http requests to blog.voina.org
In case any http requests I force https to the client by redirecting the traffic to https.

 

Define a secure reverse proxy virtual host for store.voina.org
Notice the SSLProxy configurations:

SSLProxyEngine on
Activates the ssl proxy engine

SSLProxyCACertificateFile /media/storage/www/certs/store.voina.org.cert
Specifies the location of the remote site certificates. The certificates from the keystore are used for the ssl connection between the two sites.

#SSLProxyVerify none
This is commented. In case you use some self signed certificates this has to be activated. SSL certificate verification will be disabled.

#SSLProxyCheckPeerCN off
This is commented. This disables the peer CN check. This has to be activated in case the CN of your certificate does not match the remote server CN.

#SSLProxyCheckPeerName off
This is commented. This disables the peer name check. This has to be activated in case the server name from your certificate does not match the remote server name.

#SSLProxyCheckPeerExpire off
This is commented. This disables the peer certificate expiration check. This has to be activated in case your certificate is expired

ProxyPass / https://192.168.2.22:443/
ProxyPassReverse / https://192.168.2.22:443/
With this we specify to what remote site to reverse proxy all the requests and from what remote site to get the answer.

See bellow the definition of the reverse proxy Virtual Host

 

Define a standard virtual host on the second site
In case of the store.voina.org the configuration on the second site looks like the following. Notice that is a pretty standard configuration of a SSL site, there is no indication in the configuration that the site sits behind a reverse proxy.

 

Note that on both sites we have to define the “Activate SSL section”. As we know a https connection cannot be broken by the proxy. It means that we have to have the following:
1. https connection between the client and the proxy (so the proxy has to have a SSL section using the store.voina.org certificate)
2. https connection between the proxy and the store server (so the proxy has to have a SSL section using the store.voina.org certificate)

This way the client is able to certify that is connected to the store.voina.org and also the store is able to see that the client (the proxy in this case) is using a store.voina.org certificate also.

Advertisements