This is a guide on how to run your own gateway server instead of using the donation-basis shared gateway of gateway co-op.
Note that the gateway uses TLS-passthrough, so requests to your server are encrypted all the way to your server, even when using the gateway.
But if you would still like to run your own, you can use the code we use for the gateway here.
Alternatively, there are a number of similar software projects you could also check out: cloudflare tunnel, awesome-tunneling, https://github.com/hintjen/selfhosted-gateway, pangolin.