feature request: AppSync Events: let the realtime endpoint accept a proxied host, so an application served through a reverse proxy keeps its live updates #91
mattiarossi
started this conversation in
Feature Requests (AWS)
Replies: 1 comment
|
Hi @mattiarossi. Thanks for the detailed writeup. We created an internal feature request. I will let you know once there are any updates. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
One more feature request, I understand this is pretty specific, it would enable us to progress into our plan to evaluate creating an air gapped version of our app/enabling a local dev environment to be consumed by multiple devs, in a dev sandbox/external ci/tester context
Is there an existing issue for this?
dev; this is the host check of the realtime endpoint, a different thing; the AWS-parity form of it, a custom domain on an Event API, is not supported either:associate-apiwith an Event API id answersNotFoundException: API not foundon dev1137)Feature description
The Events realtime endpoint checks the
hostthe client writes into its auth payload (theheader-<base64url {host, …}>subprotocol on the upgrade, andauthorization.hostin everysubscribeframe) against the API's own DNS name,<dns id>.appsync-api.<localstack host>:4566, and refuses anything else. That is what AWS does too, and on AWS the way to serve the API under another name is a custom domain on the Event API. LocalStack has custom domains for GraphQL APIs only. The ask: a way for a client that reaches the emulator under another name to subscribe. Either of these, the first being AWS parity:associate-apiaccepts an Event API id, and the realtime endpoint andPOST /eventaccept the associated domain as the payload'shost(and serve it as a virtual host, as the GraphQL custom domains already are).Hostheader as the authority for the connection (a reverse proxy sets it to the API's name, so the payload'shostis then compared against what the proxy vouches for), or a configured list of allowed hosts.Why it matters
The standard local deployment serves one machine:
localhost.localstack.cloudand every name under it are a public DNS wildcard that resolves to127.0.0.1from any resolver, so on any other machine the API's name points at that machine's own loopback. A team that wants the application on other devices on the network (a phone, a second laptop, a reviewer) puts a reverse proxy in front of LocalStack under a name that does resolve to the host. Pages, GraphQL, Cognito and the Events publish endpoint work through it; the websocket does not, because a browser client writes the name it was given (the proxy's) into the auth payload, so the application loses its live updates on every device but one. The alternative today is the remote-host deployment: a customLOCALSTACK_HOSTwith a wildcard DNS record on the network and a certificate for the gateway, which works (we run it) but is a different setup from the one the documentation leads to. Per-device name mapping (a hosts entry per DNS id, which changes with every API) is the other way, and not possible on a phone or a locked-down device.Reproduction, no application: LocalStack, a reverse proxy, a websocket client
Run against
localstack/localstack:dev2026.11.0.dev1137 on 2026-11-18 (the same results on dev993, 2026-11-15). The AWS CLI against the emulator; Node 20 with thewspackage for the client; Docker for the proxy.repro-events-host.mjs(the handshake amplify-js and the AWS SDK perform; thehostwritten into the auth payload is the second argument):hostin the auth payload$H), direct or through the proxyconnection_ack,subscribe_successconnection_error"Invalid host header" on connect, thensubscribe_errorHttpNotFoundExceptionon the subscribe frameA browser client cannot do the third form: it takes the host from the endpoint URL it was given, the proxy's. The HTTP
Hostheader of the upgrade request (the API's name, set by the proxy) plays no part in the check today, which is what option 2 would change. The custom-domain route, option 1, stops atassociate-api:Cleanup:
docker rm -f repro-proxy,aws appsync delete-channel-namespace --api-id "$E" --name ns,aws appsync delete-api --api-id "$E", and for the domain routedelete-domain-nameanddelete-certificate.How are you starting LocalStack?
Docker Compose under Portainer (LocalStack Pro,
localstack/localstack:dev2026.11.0.dev1137,PERSISTENCE=1), the AWS CLI, Node 20 withws, Caddy 2 as the proxy, from a workstation on the same LAN.Environment
localstack/localstack:dev, Pro token); the same on dev993ws8, Caddy 2All reactions