Handle SSL Offloading

When a server is behind a load balancer that is doing
SSL offloading, traffic between the LB and the server is http.
Thus the server will think its base url is http instead of https.
The generally accepted way to fix this is to use the HTTP_X_FORWARDED_PROTO http header. Additionally in my testing the port was still showing as 80 which is why I use "&& $port != 80" 
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields