I’m running two apps:
- A web app + proxy combo in one app. The proxy is in front of the web app and forwards any requests to
/api
to the api server and all other requests get forwarded to the web app. - The api server: simple node express/ws server listening on
/api
My API server will handle http requests as well as websocket requests.
Currently, the proxy forwards http requests just fine, but fails to forward the websocket requests, they just hang indefinitely
You can see the behavior here, using this to test the wss:// urls:
Accessing API from web app:
https://new.ayoubd.com/api/hello (works)
wss://new.ayoubd.com/api (not working)
Accessing API directly:
https://api.ayoubd.com/api/hello
wss://api.ayoubd.com/api (works, receives message every 1s)
This all works locally in dev when I run both servers, and also when I run the site locally and point my local proxy directly to api.ayoubd.com, which leads me to think this has something to do with specifically my fly.io deployment. Does anyone have any ideas about what’s going on?
Site fly.toml:
app = ...
primary_region = ...
[build]
dockerfile = "Dockerfile"
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
[[vm]]
size = "shared-cpu-1x"
memory_mb = 512
api server fly.toml:
app = ...
primary_region = ...
[build]
dockerfile = "Dockerfile"
[http_service]
internal_port = 3001
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 256