Refactor server to listen on http and https