fixes ZEN-10145: added smart safe cookies for servers set to SSL

port of https://dev.zenoss.com/tracint/changeset/79960
fixing https://jira.zenoss.com/browse/ZEN-10146

notice that 4.x checks for HTTP_X_URL_SCHEME=https, but 5.x checks for HTTP_X_FORWARDED_PROTO =https due to all browser requests going through zproxy