Fixed #39 by relying on the x-forwarded-proto header.
Thanks to @martinei, @phaus and @offlinehoster