Skip to content

Restrict NGINX to Cloudflare IPs only #3439

Open

Description

@MattIPv4

Currently, anyone can access direct.nodejs.org, bypassing the Cloudflare CDN, caching and protection. It is relatively well documented that folks are using this to get around some of the blocking that was put in place for misconfigured Artifactory instances etc.

The NGINX config should be updated such that it only accepts connections from Cloudflare, removing the ability to make HTTP requests to direct.nodejs.org. As I understand it, the hostname itself needs to remain (unproxied) for SSH access etc., but I don't believe there is any need for direct HTTP access, so I believe this should be fine to do?

Activity

  1. targos commented on Aug 4, 2023

    @targos
    Member

    +1

    I guess using iptables configuration might be better to avoid server overload, but if NGINX config is much easier to change, it's fine too.

  2. nschonni commented on Aug 4, 2023

    @nschonni
    Member

    It is relatively well documented that folks are using this to get around some of the blocking that was put in place for misconfigured Artifactory instances etc.

    Wouldn't the solution to that be to copy the cloudflare agent filtering rules down to NGINX for the requests to the direct.nodejs.org.
    I thought the point of that endpoint was a "break glass" when cloudflare caching got messed up, so restricting to only CloudFlare IPs would defeat it's purpose

  3. MattIPv4 commented on Aug 4, 2023

    @MattIPv4
    MemberAuthor

    Wouldn't the solution to that be to copy the cloudflare agent filtering rules down to NGINX for the requests to the direct.nodejs.org.

    direct.nodejs.org isn't proxied through Cloudflare, so that wouldn't be possible. If it were to be proxied, it might as well just be removed at that point IMO.

    I thought the point of that endpoint was a "break glass" when cloudflare caching got messed up, so restricting to only CloudFlare IPs would defeat it's purpose

    Maybe it is, and I've misunderstood its purpose. If that is the case though, it is forever going to get used by folks who want to get around blocking etc., or just don't know any better, and will keep putting additional load on the origin with no caching (and leave the origin incredibly open to DDoS etc.).

  4. nschonni commented on Aug 4, 2023

    @nschonni
    Member

    direct.nodejs.org isn't proxied through Cloudflare, so that wouldn't be possible. If it were to be proxied, it might as well just be removed at that point IMO.

    I'm not saying proxying it through cloudflare, I mean just copy those same firewall rules to nginx https://www.cyberciti.biz/faq/unix-linux-appleosx-bsd-nginx-block-user-agent/ if you think people are using it to bypass those specific rules

  5. MattIPv4 commented on Aug 4, 2023

    @MattIPv4
    MemberAuthor

    Ah yeah, we could move the restrictions to NGINX as well as Cloudflare (or remove them from Cloudflare at that point). It still leaves the origin exposed to the world without caching though, which isn't great :/

  6. github-actions commented on May 31, 2024

    @github-actions

    This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

  7. MattIPv4 commented on May 31, 2024

    @MattIPv4
    MemberAuthor

    I don't believe this is stale, as NGINX is still serving some routes via Cloudflare.

  8. flakey5 commented on May 23, 2025

    @flakey5
    Member

    Sorry for bumping an old issue, but I'm curious if Access would be a good use case here?

    I agree that direct.nodejs.org shouldn't necessarily be publicly accessible, but it can be helpful when debugging issues with the release worker.

    This way the ports would still be open to Cloudflare ips only but people could still send requests to it directly if need be (given they have access)

  9. targos commented on May 25, 2025

    @targos
    Member

    That sounds like a good idea!

  10. flakey5 commented on Jul 28, 2025

    @flakey5
    Member

    Shouldn't be too complicated but just realized it would mess with ssh.

    Actually doing it just needs an access policy that allows the necessary emails for otp or if we wanna use an idp, then creating a self-hosted application w/ the direct.nodejs.org public hostname & using that access policy.

    But, this would cover any traffic on any port going to direct.nodejs.org and not just http, ssh can be used over access ofc but there would need to be changes to CI

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions