BackendStack21/fast-gateway

How to properly support HTTP and HTTPS

Closed this issue · 2 comments

Does fast-gateway support listening for both HTTP and HTTPS? If so, what's the correct way to set that up?

Hi again @clarktlaugh, fast-gateway uses restana as HTTP framework, restana only supports one http.Server https://nodejs.org/api/http.html#http_class_http_server instance, so there is no way to support 2 listening ports out of the box.
What you can do is to run two http.Server instances and inject the requests into fast-gateway.

See the example below:

const restana = gateway({
  routes: [{
    ...
  }]
})
const bridge = restana.callback()

const server1 = http.createServer(bridge)
// ...

const server2 = http.createServer(bridge)
//...

Here I setup 2 plain HTTP servers and forward the requests to restana, you can use this example to spin up as many servers as you need, HTTP, HTTPS, HTTP2, etc...

Thanks and Regards.

NOTE: You can also read more about fast-gateway in here: https://medium.com/@kyberneees/node-js-api-gateway-a-developer-perspective-8defe575ed21

Thank you -- after sleeping on it, I realized it was a dumb question :) Thank you for your answer.