Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make frontend listen on both IPv4 and IPv6 by default #19660

Merged
merged 4 commits into from
Nov 10, 2023

Conversation

n-thumann
Copy link
Contributor

@n-thumann n-thumann commented Nov 10, 2023

This PR drops the default listening IPv4 address for the frontend and subsequently enables IPv4 + IPv6 (Dual Stack) for it by default.
Enforcing to listen on 0.0.0.0 by default artificially limits a user to access the frontend via IPv4-only. This means it cannot be accessed via IPv6 at all.
As long as a user doesn't explicitly configures IPv4-only, I think the frontend should be available on both stacks by default.

My changes allow frontend.host to also be null, so that listen() will be called with no host, but the port only. When called without a host, listen() will listen on all interfaces on both IPv4 and IPv6 (https://nodejs.org/docs/latest/api/net.html#serverlistenport-host-backlog-callback).
This behavior has the advantages that

  • users, who don't care about this, won't experience any difference, because IPv4 will still be bound
  • users, who care about IPv6 will be able to the frontend out-of-the-box

Manually specifying host: "0.0.0.0" (to keep binding IPv4-only) is of course still possible.
If IPv6 is disabled system-wide (e.g. by setting sysctl net.ipv6.conf.all.disable_ipv6 1), Node.js will fallback to binding IPv4-only.

I tested these changes by the following setups and the default config of frontend: true:

  1. Running it in an dual-stacked VM: The frontend is available via both IPv4 and IPv6
  2. Running it in an IPv6-only VM: The frontend is available via IPv6
  3. Running it in an IPv4-only VM (IPv6 disabled via sysctl): The frontend is available via IPv4

@Koenkk Koenkk merged commit 45ac44d into Koenkk:dev Nov 10, 2023
@Koenkk
Copy link
Owner

Koenkk commented Nov 10, 2023

Thanks! I think this also deserves to be mentioned on the docs, could you also make a PR for that?

@n-thumann
Copy link
Contributor Author

Sure, will take care of that! Thanks for the quick merge ✌🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants