Hello, I’m using http1 server for web socket and http2 server for https server in my fastify app.
It works fine with local environment(docker)
My code looks something like this
const fastifyHttp = Fastify({
logger: true,
});
const fastifyHttps = Fastify({
logger: true,
http2: true,
...(process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "staging"
? {
https: {
allowHTTP1: true,
key: fs.readFileSync("./ssl/localhost-key.pem"),
cert: fs.readFileSync("./ssl/localhost-cert.pem"),
},
}
: {}),
});
...
const PORT_HTTP = Number(process.env.PORT_HTTP) || 3000;
const PORT_HTTPS = Number(process.env.PORT_HTTPS) || 3443;
await fastifyHttp.listen({ port: PORT_HTTP, host: "0.0.0.0" });
await fastifyHttps.listen({ port: PORT_HTTPS, host: "0.0.0.0" });
and this is my fly.toml
app = "threader-be-staging"
primary_region = "nrt"
[build]
dockerfile = "Dockerfile"
[[services]]
internal_port = 3443
protocol = "tcp"
force_https = true
processes = ["app"]
[[services.ports]]
handlers = ["tls", "http"]
port = 443
tls_options = { "alpn" = ["h2", "http/1.1"], "versions" = ["TLSv1.2", "TLSv1.3"] }
[[services.tcp_checks]]
interval = "10s"
timeout = "2s"
[[services]]
internal_port = 3000
protocol = "tcp"
force_https = false
processes = ["app"]
[[services.ports]]
handlers = ["http"]
port = 80
[[services.tcp_checks]]
interval = "10s"
timeout = "2s"
[[vm]]
memory = "512mb"
cpu_kind = "shared"
cpus = 1
What I’m getting is 502 error for any request.
And my macine log says
[PU02] could not complete HTTP request to instance: invalid HTTP version parsed
I think it can be fixed with right toml file configuration. What am I missing here?