Refactor server to listen on both http and https