Skip to content

Make the API/GraphQL server bind address configurable (respect LISTEN_ADDR) #1802

Description

@Marvelous2095

Is there an existing issue for this?

  • I have searched the existing open and closed issues

Is your feature request related to a problem? Please describe

Current behavior: LISTEN_ADDR only applies to nginx (UI, PORT). The API/GraphQL server (server/api_server/api_server_start.py) is started with a hard-coded app.run(host="0.0.0.0", port=graphql_port, …). With LISTEN_ADDR=127.0.0.1 (typical when running behind a reverse proxy, network_mode: host) the UI listens on loopback only, but GRAPHQL_PORT (20212) stays reachable on every interface:

$ ss -ltn | grep -E ':2021[12] '
LISTEN 0  511  127.0.0.1:20211  0.0.0.0:*
LISTEN 0  128    0.0.0.0:20212  0.0.0.0:*

Access is protected by API_TOKEN (a request without a valid token gets 403 Forbidden), so this is a hardening / defense-in-depth request, not a vulnerability report. It is still unexpected, and in this setup not needed: nginx already proxies to the API via http://127.0.0.1:${BACKEND_PORT} (netalertx.conf.template).

The docs also read as if LISTEN_ADDR covered the whole container ("Listen for connections on all interfaces" in the Docker Compose guide).

Verified on the 26.9.0 release image (app.run(host="0.0.0.0", …) at line 2132) and on netalertx-dev:latest (image f854bec8bc7c, revision cd1d0ed; same hard-coded value at line 2205).

Describe the solution you'd like

Proposal: make the API server bind address configurable. Either use LISTEN_ADDR for the API server as well, or add a separate variable (e.g. GRAPHQL_LISTEN_ADDR). It must stay opt-in / default to 0.0.0.0, because existing setups depend on the API being reachable from other hosts: for example Sync Hub nodes push to the hub's API port over the network (SYNC_hub_url='http://<hub>:20212', see #1698). A separate variable avoids changing behavior for anyone who already sets LISTEN_ADDR only for the UI.

Please also mention the scope of LISTEN_ADDR / the new variable in the docs.

Describe alternatives you've considered

  • Workaround I use: mount a one-line patched copy of api_server_start.py (host="127.0.0.1") read-only into the container. It works, but has to be regenerated on every image update, and the image is pinned by digest in my setup.
  • Host firewall rule for the port: works, but needs a firewall on the host and is easy to forget.

Anything else?

Am I willing to test this? 🧪

  • I will do my best to test this feature on the netlertx-dev image when requested within 48h and report bugs to help deliver a great user experience for everyone and not to break existing installations.

Can I help implement this? 👩‍💻👨‍💻

  • Yes
  • No

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature request ➕New feature or requestwont do 🚫This will not be worked on. I might be open to PRs - check with me before starting work.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions