Add SSL detection and proper redirection

Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>