NodeBB + Cloudflare Caching

Technical Support
  • NodeBB's Documentation contains some instructions on how Nginx can be modified in order to scale NodeBB:

    location @nodebb {
        proxy_pass http://127.0.0.1:4567;
    }
    
    location ~ ^/assets/(.*) {
        root /path/to/nodebb/;
        try_files /build/public/$1 /public/$1 @nodebb;
    }
    
    location /plugins/ {
        root /path/to/nodebb/build/public/;
        try_files $uri @nodebb;
    }
    

    If I understand it correctly, static resources will be served faster this way.

    I wanted to apply the same logic to Cloudflare caching. Are there instructions anywhere on how to do this properly? For now, I've created 2 Page Rules:

    • /plugins/* - Cache Level: Cache everything
    • /assets/* - Cache Level: Cache everything

    The problem with this "Cache everything" setting is that query strings are not ignored. So these 2 requests take 2 keys in the cache, even though it's the same document:
    GET /assets/src/modules/composer/tags.js?v=17etv7hm589 127.0.0.1
    GET /assets/src/modules/composer/tags.js?v=23etv7hm589 127.0.0.1

    If I use "Ignore query string", then the request below isn't cached because Cloudflare doesn't cache *.json files by default (only if you use the "Cache everything"):
    GET /assets/src/modules/composer/tags.js?v=17etv7hm589 127.0.0.1

    It seems that it's possible to cache everything while ignoring query strings, but only on Enterprise plans. I'm currently using the Pro plan.

    Anyways, if anyone has any tips on how to optimize NodeBB with Cloudflare, I'd appreciate it.

  • @brandt said in NodeBB + Cloudflare Caching:

    The problem with this "Cache everything" setting is that query strings are not ignored.

    Is this really a problem? The query string only changes when you run ./nodebb build, so generally you should only have a single one.

  • @PitaJ Cool! If the query string only changes on ./nodebb build then "Cache everything" works well. I thought the query string was different for each user or represented some token/cookie. I guess I should have checked how it is generated before posting.


Suggested Topics


  • NodeBB on Oracle VPS [I need help!]

    Unsolved Technical Support
    4
    0 Votes
    4 Posts
    284 Views

    Your issues with firewall are likely because Oracle is, essentially, using firewalld rules for all their images, even ones that don't have it included. So if you are running on Ubuntu, and trying to use ufw like most tutorials will recommend you do, it will do nothing with the default iptables entires and be essentially useless. And the bigger problem is that some of their rules are required to start to VMs (they need iSCSI access rules on boot)

    The easy solution is to just give in to Oracle's config and install firewalld:

    sudo apt install firewalld sudo systmctl enable --now firewalld

    (And ensure ufw is disabled)

    You can then manage rules using firewall-cmd. For example:

    sudo firewall-cmd --permanent --add-service={http,https} sudo firewall-cmd --reload

    Will allow http/https traffic.

    The second option is the one I assume you tried: fix iptables and use ufw. But this is a bit more complex than it seems.
    First issue is that IIRC the iptables rules will be applied again on reboot. Now, cloud init can be disabled, but there is another issue - the iSCSI rules.
    The official Oracle workaround for ufw potentially making the VMs unbootable is "don't use ufw" (https://docs.oracle.com/en-us/iaas/Content/knownissues.htm#ufw), and while you should be able to just ensure everything is correctly configured with ufw, I honestly stopped bothering. firewalld works fine for me, so, like Oracle, I would recommend that route instead.

    Additionally there is separate OCI networking and their firewall. You have to remember that Network Security Groups override Security Lists, so if you have one assigned to your VNIC, you need to edit it instead of the subnet-wide SL.

    If there is something else specifically you need help with you'll need to give more details - this post is just based on a guess you have the common issues.

  • 0 Votes
    19 Posts
    2k Views

    @arnaudw
    I installed a new forum on a heroku server and when I connect via myapp.herokuapp.com it works great
    But when I connect through my domain it is written to me "welcome back guest" but really stayed disconnected
    (I only use a subdomain, at the domain root I use for another site, I use cloudflare I set ssl and force ssl)
    I would be happy to help, thanks

  • 0 Votes
    4 Posts
    352 Views

    I figured it out, soon as I put the FQDN into config.json, the FQDN address started working and the local IP stopped. Good enough for me.

  • 1 Votes
    6 Posts
    839 Views

    I never got around to doing anything with it.

    We have a few gaming sites and I wanted to have one userbase between them all.

  • 0 Votes
    4 Posts
    1k Views

    @PitaJ Worked, thanks 🙂 For some reason I had the idea cd wouldn't work there