Better support SSL through proxified server

Add support for HTTP header HTTP_X_FORWARDED_PROTO with https mode.