Enhance SSL detection

In some advanced environments - $_SERVER['HTTPS'] is not available. Check for and use $_SERVER['HTTP_X_FORWARDED_PROTO'] in that case.

One known use case is running behind a load balancer that terminates SSL @ the load balancer and passes port 80 over the private network behind it.