eidheim / Simple-Web-Server

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
MIT License
2.62k stars 755 forks source link

Redirecting HTTP to HTTPS #171

Closed alandefreitas closed 6 years ago

alandefreitas commented 6 years ago

I'm sorry if that's a stupid question but... when I run a Server, can I redirect a request from http://localhost:8080/ to https://localhost:8080/ without creating two servers?

eidheim commented 6 years ago

Not a stupid question at all, but currently one would need one server for each port you wish to accept connections on. That is, in your case you would need two servers.

eidheim commented 6 years ago

But both servers can of course share the same asio::io_service if that is favourable.

eidheim commented 6 years ago

Oh, you need to different ports for HTTP and HTTPS. Defaults are 80 for HTTP, and 443 for HTTPS.