Search code examples
swiftserver-sidevapor

Can Vapor 4 serve both HTTP and HTTPS requests in the same application?


I have a Vapor 4 app which is successfully serving HTTPS requests with no issues.

I would like it to also respond to HTTP requests on a custom port number, which will be for providing some back-end control and monitoring hooks that are called by other services on the same server, and won't be publicly reachable.

When I search Google and browse the Vapor docs for how to do this, I only get results for a very old version of Vapor, using a configuration file to specify HTTP/HTTPS server and port configurations.

Does anyone know if this type of configuration be done on Vapor 4?

Cheers and thanks in advance!


Solution

  • No Vapor 4 cannot serve different protocols on the same port/application. The easiest way around is to run two instances of the application, one for each. Or just get the internal traffic to use HTTPS.

    Another option would be to stick Nginx in front or similar