fixed https support (is_secure() is not reliable in some scenarios, like when it's behind an ssl terminating proxy)