How can you detect SSL offload on server behind a load balancer?
In our production environment the SSL is offloaded to the load balancer. This was done to reduce the CPU load on the servers.
For the most part this is perfectly fine, however, we now need the servers to be aware whether they are serving pages over SSL or not.
What is a good way of doing this, but keeping the SSL offload in place?
Solution 1:
You could add a header sent to the backend server containing the scheme
For example, using NGINX I'd send a header to the backend proxy server with the $scheme variable,
proxy_set_header Scheme $scheme;
Then in your backend application you could get the header;
if ( this.request.getheader('Scheme') is 'http' ) {
this.response.send('HTTP!')
} otherwise ( this.request.getheader('Scheme') is 'https' ) {
this.response.send('HTTPS!')
}
What load balancer are you using? I'm sure there will be a way to do something similar in most software, I just happen to know NGINX best