• Global Moderator Plugin & Theme Dev

    @esteban-constante yes using Nginx to serve static assets would absolutely help.

  • GNU/Linux Admin

    Using nginx to serve static assets takes the load off of NodeBB to serve pre-compiled things like nodebb.min.js, module files, etc... nginx is exceedingly good at doing that.


  • So min. one core has to be used for nginx? And if that's not enough I have to use a load balancer and use something like 2 Server a 8 cores. Both servers with clustering...?


  • @julian Just checked my nginx conf, it's basically the same as the one in the tutorial:

    upstream io_nodes {
        ip_hash;
        server 127.0.0.1:4567;
        server 127.0.0.1:4568;
        server 127.0.0.1:4569;
    }
    
    > server {
        listen 80;
        server_name community.nodebb.org;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_redirect off;
        # Socket.io Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        gzip            on;
        gzip_min_length 1000;
        gzip_proxied    off;
        gzip_types      text/plain application/xml text/javascript application/javascript application/x-javascript text/css application/json;
        location @nodebb {
            proxy_pass http://io_nodes;
        }
        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;
        }
        location / {
            proxy_pass http://io_nodes;
        }
    }
    

    So yeah, it seems I'm using nginx to serve static assets 😞

    (ninja'd by yariplus)

  • Global Moderator Plugin & Theme Dev

    Could you provide your full actual nginx config? Fell free to redact anything you think is sensitive.

    Check the headers on a request to example.com/assets/nodebb.min.js. If nginx is set up correctly, they shouldn't have an X-Powered-By: NodeBB header.


  • Here it's the conf file:

    upstream io_nodes {
        ip_hash;
        server 127.0.0.1:4567;
        server 127.0.0.1:4568;
        server 127.0.0.1:4569;
        server 127.0.0.1:4570;
        server 127.0.0.1:4571;
        server 127.0.0.1:4572;
        server 127.0.0.1:4573;
        server 127.0.0.1:4574;
    
        #16 cores:
        server 127.0.0.1:4575;
        server 127.0.0.1:4576;
        server 127.0.0.1:4577;
        server 127.0.0.1:4578;
        server 127.0.0.1:4579;
        server 127.0.0.1:4580;
        server 127.0.0.1:4581;
        server 127.0.0.1:4582;
    }
    
    server {
        listen       80;
        server_name  myserver.tld;
        return       301 http://www.myserver.tld$request_uri;
    }
    server {
        listen 80;
        server_name www.myserver.tld;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_redirect off;
        # Socket.io Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        gzip            on;
        gzip_min_length 1000;
        gzip_proxied    off;
        gzip_types      text/plain application/xml text/javascript application/javascript application/x-javascript text/css application/json;
        location @nodebb {
            proxy_pass http://io_nodes;
        }
        location ~ ^/assets/(.*) {
            root /home/myuser/nodebb/;
            try_files /build/public/$1 /public/$1 @nodebb;
        }
        location /plugins/ {
            root /home/myuser/nodebb/build/public/;
            try_files $uri @nodebb;
        }
        location / {
            proxy_pass http://io_nodes;
        }
    }
    
  • Global Moderator Plugin & Theme Dev

    @esteban-constante please use triple ticks (```) around code blocks, not quotes. For future reference


  • @pitaj fixed it. Thanks! I was trying with single and double `

  • Global Moderator Plugin & Theme Dev

    @esteban-constante have you been able to check the response headers for any static assets yet? Your nginx file looks good to me. Have you tried running with fewer NodeBB processes? It could be that your database server is being overloaded.


  • @pitaj So far I haven't been able to test the traffic spikes as I haven't had any lately 😞

    I did found a typo in my nginx file which I've fixed already and it seems to run better. I'll report back as soon as I get more data.


Suggested Topics

| | |

© 2014 – 2022 NodeBB, Inc. — Made in Canada.