Skip to content

How To: Let's Encrypt and NodeBB

Tutorials
15 9 13.0k 5
  • I already covered this in my "High performance stack" tutorial. Still a nice tutorial.

    @AOKP I just looked at your high performance tutorial. Definitely a lot of information. Possibly too much all at once. I think people may find this succinct post just related to Let's Encrypt easier to digest.

  • Edited to include a warning about using a sym link to the .well-known/acme-challenge directory.

  • @rod, is the root you specify in the nginx config arbitrary, an empty directory path that actually exists, or does it need to be the actual root of the public folder? I have a non-standard configuration where I have a dedicated user for running NodeBB, and the actual root location is in the home folder of that user (which is also non-standard, in the /usr/share/nginx dir)

    EDIT: nvm, I forgot to specify the folder to save the file in with the -w flag

    Thanks!

  • @Bri root /var/www/yourdomainhere.com/html; this one?

    It's not used by NodeBB, only by Let's Encrypt.

    It will try to access the file located in /.well-known/acme-challenge/, and that is relative to the root as defined.

    For my Let's Encrypt setup, I instead use:

      location "/.well-known/acme-challenge" {
          root /usr/share/nginx/html;
      }
    

    ... as that folder is served by nginx already, so less configuration 😄 (I modify my ./letsencrypt-auto command according as well, of course)

  • Cool, didn't know that you could put the "root" inside the location block, thanks!

  • @rod hi rod, im doing exactly what u r saying but i have a problem is where should i put the verification files? another saying is where to put these two files below to upload into
    .well-known/acme-challenge/ directory?

    nOmtkseci4NqOwrx9OYnmtQaoNsPrqq7_JG3Kf4iVd8
    NJpedX-UNHPAVRaur_ZNyiSjwpqrudSPuX2eL8PY010

    thanks.

  • I'm using a Lets Encrypt based service at https://www.sslforfree.com which allows DNS authentication instead of the two file uploads. Too much hassle to get that directory working .. 🐇

  • 0 01

    @rod hi rod, im doing exactly what u r saying but i have a problem is where should i put the verification files? another saying is where to put these two files below to upload into
    .well-known/acme-challenge/ directory?

    nOmtkseci4NqOwrx9OYnmtQaoNsPrqq7_JG3Kf4iVd8
    NJpedX-UNHPAVRaur_ZNyiSjwpqrudSPuX2eL8PY010

    thanks.

    @01 You tell nginx where to look for the files.

    server {
        listen       80;
        server_name  yourdomainhere.com;
        ...
    
        location "/.well-known/acme-challenge" {
            root /usr/share/nginx/html;
        }
    }
    

    This would mean the files you create are:

    /usr/share/nginx/html/nOmtkseci4NqOwrx9OYnmtQaoNsPrqq7_JG3Kf4iVd8
    /usr/share/nginx/html/NJpedX-UNHPAVRaur_ZNyiSjwpqrudSPuX2eL8PY010

  • @01 You tell nginx where to look for the files.

    server {
        listen       80;
        server_name  yourdomainhere.com;
        ...
    
        location "/.well-known/acme-challenge" {
            root /usr/share/nginx/html;
        }
    }
    

    This would mean the files you create are:

    /usr/share/nginx/html/nOmtkseci4NqOwrx9OYnmtQaoNsPrqq7_JG3Kf4iVd8
    /usr/share/nginx/html/NJpedX-UNHPAVRaur_ZNyiSjwpqrudSPuX2eL8PY010

    @yariplus said in How To: Let's Encrypt and NodeBB:

    @01 You tell nginx where to look for the files.

    server {
        listen       80;
        server_name  yourdomainhere.com;
        ...
    
        location "/.well-known/acme-challenge" {
            root /usr/share/nginx/html;
        }
    }
    

    This would mean the files you create are:

    /usr/share/nginx/html/nOmtkseci4NqOwrx9OYnmtQaoNsPrqq7_JG3Kf4iVd8
    /usr/share/nginx/html/NJpedX-UNHPAVRaur_ZNyiSjwpqrudSPuX2eL8PY010

    Thank you @yariplus, I have tried to reverse proxy these files over but didn't work. So I found a very easy way to do it.
    I downloaded Caddy which is a tiny open source server, and verified the files use the caddy server. Everyone use LE ssl on nodebb should do it this way, much easier.

    Now I'm encountering a new problem, I tried to setup the certificates for my nodebb but it doesn't work.

    This is my nginx config

    #user  nobody;
    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip  on;
    
    server {
        listen 80;
    
        server_name mydomain.com;
    
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
    
            proxy_pass http://127.0.0.1:4567;
            proxy_redirect off;
    
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
    		
    		
        }	
    }
    
    
    
    
    server {
        # listen on ssl, deliver with speedy if possible
        listen 443 ssl http2;
    
        server_name mydomain.com;
    
        # change these paths!
    
        ssl_certificate /cert/bundle.crt;
        ssl_certificate_key /cert/mydomain.key;
    
        # enables all versions of TLS, but not SSLv2 or 3 which are weak and now deprecated.
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    
        # disables all weak ciphers
        ssl_ciphers 'AES128+EECDH:AES128+EDH';
    
        ssl_prefer_server_ciphers on;
    
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
    
            proxy_pass http://127.0.0.1:4567/; 
            proxy_redirect off;
    
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
    
    }
    

    nodebb config

    {
        "url": "https://mydomain.com",
        "secret": "************************",
        "database": "mongo",
        "mongo": {
            "host": "127.0.0.1",
            "port": "*****",
            "username": "****",
            "password": "*****",
            "database": "****",
            "uri": ""
        },
        "port": "4567"
    }
    

    Any idea why it doesn't work?

  • 0 01

    @yariplus said in How To: Let's Encrypt and NodeBB:

    @01 You tell nginx where to look for the files.

    server {
        listen       80;
        server_name  yourdomainhere.com;
        ...
    
        location "/.well-known/acme-challenge" {
            root /usr/share/nginx/html;
        }
    }
    

    This would mean the files you create are:

    /usr/share/nginx/html/nOmtkseci4NqOwrx9OYnmtQaoNsPrqq7_JG3Kf4iVd8
    /usr/share/nginx/html/NJpedX-UNHPAVRaur_ZNyiSjwpqrudSPuX2eL8PY010

    Thank you @yariplus, I have tried to reverse proxy these files over but didn't work. So I found a very easy way to do it.
    I downloaded Caddy which is a tiny open source server, and verified the files use the caddy server. Everyone use LE ssl on nodebb should do it this way, much easier.

    Now I'm encountering a new problem, I tried to setup the certificates for my nodebb but it doesn't work.

    This is my nginx config

    #user  nobody;
    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip  on;
    
    server {
        listen 80;
    
        server_name mydomain.com;
    
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
    
            proxy_pass http://127.0.0.1:4567;
            proxy_redirect off;
    
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
    		
    		
        }	
    }
    
    
    
    
    server {
        # listen on ssl, deliver with speedy if possible
        listen 443 ssl http2;
    
        server_name mydomain.com;
    
        # change these paths!
    
        ssl_certificate /cert/bundle.crt;
        ssl_certificate_key /cert/mydomain.key;
    
        # enables all versions of TLS, but not SSLv2 or 3 which are weak and now deprecated.
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    
        # disables all weak ciphers
        ssl_ciphers 'AES128+EECDH:AES128+EDH';
    
        ssl_prefer_server_ciphers on;
    
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
    
            proxy_pass http://127.0.0.1:4567/; 
            proxy_redirect off;
    
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
    
    }
    

    nodebb config

    {
        "url": "https://mydomain.com",
        "secret": "************************",
        "database": "mongo",
        "mongo": {
            "host": "127.0.0.1",
            "port": "*****",
            "username": "****",
            "password": "*****",
            "database": "****",
            "uri": ""
        },
        "port": "4567"
    }
    

    Any idea why it doesn't work?

    @01 it's not "much easier", it's just wrong. If you don't use nginx to do it, you'll not be able to do automatic renewal correctly.

    Is nginx running? It doesn't look like you actually modified your nginx config to include the static serving for acme challenge. Have you verified that the nginx config is valid?

  • @01 it's not "much easier", it's just wrong. If you don't use nginx to do it, you'll not be able to do automatic renewal correctly.

    Is nginx running? It doesn't look like you actually modified your nginx config to include the static serving for acme challenge. Have you verified that the nginx config is valid?

    @PitaJ said in How To: Let's Encrypt and NodeBB:

    @01 it's not "much easier", it's just wrong. If you don't use nginx to do it, you'll not be able to do automatic renewal correctly.

    Is nginx running? It doesn't look like you actually modified your nginx config to include the static serving for acme challenge. Have you verified that the nginx config is valid?

    @PitaJ Sorry for the confusion, these two configs are for trying to setup ssl certificates on my nodebb, I have already verified with the acme challenge with the static server. I have got the ssl certificates already with the static server, with nginx I just don't know how to get it to work. So I gave up.

    Im trying to get ssl work on my nodebb and I've been search everywhere but still can't get it to work, any suggestions? I think this nginx config should be valid, because nginx runs with this cinfg file. if there are errors in the config normally nginx wont run at all.

    I got my certificates issued from this website https://zerossl.com/, to renew the certificates they said only require the csr file, so I have to manually renew it anyway. I hosted my nodebb on windows 10 so it's different to many of the docs and so hard to get everything to work.

  • 0 01

    @PitaJ said in How To: Let's Encrypt and NodeBB:

    @01 it's not "much easier", it's just wrong. If you don't use nginx to do it, you'll not be able to do automatic renewal correctly.

    Is nginx running? It doesn't look like you actually modified your nginx config to include the static serving for acme challenge. Have you verified that the nginx config is valid?

    @PitaJ Sorry for the confusion, these two configs are for trying to setup ssl certificates on my nodebb, I have already verified with the acme challenge with the static server. I have got the ssl certificates already with the static server, with nginx I just don't know how to get it to work. So I gave up.

    Im trying to get ssl work on my nodebb and I've been search everywhere but still can't get it to work, any suggestions? I think this nginx config should be valid, because nginx runs with this cinfg file. if there are errors in the config normally nginx wont run at all.

    I got my certificates issued from this website https://zerossl.com/, to renew the certificates they said only require the csr file, so I have to manually renew it anyway. I hosted my nodebb on windows 10 so it's different to many of the docs and so hard to get everything to work.

    @01 What is the error you are receiving when you visit your site?

    If you can access your site, but it says the connection is insecure, then part of your certificate chain is missing or invalid.


Suggested Topics


  • 0 Votes
    29 Posts
    2k Views
    Scott Williams 🐧V
    @mdione As of now, cert-manager refuses to give an option to just do the full chain because they view it as unnecessary and wasteful, but they get requests over it regularly. Likewise, Red Hat has refused to budge in their belief that they are simply following the spec.
  • How to profile NodeBB

    Tutorials
    2
    2 Votes
    2 Posts
    1k Views
    gotwfG
    @baris Good stuff! Flame graphs - not just for Solaris anymore. Hip, hip, hooray for portable software engineering. Those interested in a bit deeper dive may want to check out Brendan Gregg's blog.
  • NodeBB Email - Postfix Null Client

    Tutorials email
    1
    0 Votes
    1 Posts
    3k Views
    gotwfG
    Who Is This Document For? Well... like most things.... it depends.... If one or more of following shoes fits: Just want to get NodeBB up and running with minimum of hassle please I refer you to the tl;dr commentary from my NodeBB Email Options article. Intermediate to advanced Linux user. You can likely get this on your own. May be of some value to those unfamiliar with network and server side aspects of SMTP? Seasoned email administrator? Right. Please do not be too harsh as I'm endeavoring to bridge a gap here... SME commentary welcome. If, on the other hand: You're attracted to the "Ops" side of DevOps. Like to know how things work. Medium/advanced "beginner" to the Unix/Linux command line and eager to learn. Have the time to invest in that learning (i.e. big boss man or some other urgency not twisting your arm to get this done yesterday) and not afraid to RTFM. Then....... For Those About to Rock... I confess to deploying a Null Client set up for my forums. I thought I'd expand upon this a bit for interested parties not already possessing subject matter expertise but comfortable with the command line and willing to roll up their sleeves. Follows is meant to be a thumbnail sketch to get the DIY inclined pointed in the proper directions rather than exhaustive step by step copy pasta. Firstly, let's take a look at some reasons why/when this use case may be a fit: Isolation and separation of duties. Some favor an all on one approach. I favor dedicated vm's for dedicated tasks. I'd rather not have my app servers initiating connections with the Big Bad Internet. Incoming http(s), smtp, etc. requests from non local VM's is proxied. Access to prexisting email infrastructure. Security and stability concerns. All software has bugs. Postfix has weathered extensive scrutiny and audit. As such, I expect it is less vulnerable to things like malformed responses. Flexibility moving forward. For e.g. you want a daemon to manage NodeBB's outgoing mail queue - and perhaps that daemon also comes in handy for other duties like emailing various reports or alerts to administrators. Presumptions: You have a Postfix Null Client configured as outlined in the Postfix Standard Configuration Readme. You have NodeBB configured to utilize such as depicted in my screenshot in my prior article linked above. I've mentioned this can get complex in a hurry. Let's see if we give it a little K.I.S.S. Incoming!! Let's get our biggest hurdle out of the way. Null clients do not receive incoming mail. Setting up SMTP relays, IMAP server, virus/malware scanner, etc. ups the ante considerably. We've already got enough on our plates, at least for now, embarking upon this Null Client journey so lets save ourselves some grief and off load those duties to a reputable third party service such as Proton Mail. Outgoing As always, there's more than one way to do it: Null client delivers email directly to one of the servers listed in recipient domains MX records. Null client forwards email to a dedicated SMTP relay host, e.g. the folks handling your incoming mail (you may need to coordinate with them to configure some knobs, e.g. which hosts they will relay email from). Advantages to using a relay host include: 1) Undeliverable mail does not get stuck on your NodeBB server, and 2) Our null client is now initiating outgong SMTP connections with only the relayhost(s) rather than the big bad Internet at large. Postfix needs to know about your relay host to get this working. Add the following line to your null client's main.cf relayhost = your-relay-host.domain.tld You may also choose to specify relayhost via alternate parameters, such as IP address. I recommend sticking with hostnames as IP addresses may change from time to time. DNS Record Cogs & Widgets DNS presents yet another challenge and can have a high price for mistakes. So you're best off offloading this to a third party. Good news is your email provider likely bundles this with their service. Your domain registrar surely does. Consider leveraging that. Submit a request to have forward and SPF records added for your NodeBB instance's hostname. Note: I've used traditional Bind zone file syntax in the examples below. Using this syntax in help desk requests helps avoid confusion. Your provider may well offer a web based UI. You want records that look similar to the following (mind the trailing periods on fully qualified host names): Forward Record null-host-name.your-domain.tld. IN A XXX.YYY.WWW.ZZZ SPF Record The purpose of an SPF record is to provide a list of servers authorized to send email from your domain and must therefore necessarily include your third party provder's servers as well as your null client(s). your-domain.tld. IN TXT "v=spf1 ip4:primary-ip, ip4:secondary-ip, ip4:null-host-ip -all" MX Records Your mailbox provider likely handles configuration of MX records seamlessly but for the sake of completeness.... RFC's dictate primary and secondary mail exchangers. Get these from your mailbox host. @ IN MX 50 primary-mx.domain.tld. @ IN MX 80 secondary-mx.domain.tld. Reverse Record Your cloud provider is authoritative for reverse records for IP space assigned to them. Set up a PTR record for your NodeBB host using your providers management ui or submit a request ticket for them to create such for you. XXX.YYY.WWW.ZZZ.in-addr.arpa. IN PTR null-host-name.your-domain.tld. I manage my own DNS servers. DKIM is a royal pita for even seasoned adminstrators and imho an accident waiting to happen. Hence, unless you have a passion for learning about this stuff, I recommend letting your email/IMAP provider handle DNS for you, as it is lots easier to have them add an A or CNAME record as necessary for web servers and such than for you to configure and maintain DKIM. Else avoid DKIM entirely. Postmaster Other systems expect the existence of a valid postmaster address for communication of issues such as bounced mail, etc. Create "[email protected]", either as a dedicated mailbox or a forward to an existing mailbox, e.g. [email protected] if you prefer not having to check multiple mailboxes. Test this. Don't sweep postmaster mail under the rug lest it come back to haunt you at the most inopportune of times. Blacklists We need to ensure our newly minted Null Client is not blacklisted. MX Toolbox offers a meta blacklist check. Barracuda Networks will most likely do so before you've sent even a single email and requires jumping thru their hoops to become delisted. And jump ye' shall because their stuff is in wide spread use, particularly corporate side. It behooves you to check these blacklists from time to time, particularly with a newly minted server. Bippity Boppity Boo! Put it together and what have we got? Robust SMTP daemon relaying outgoing NodeBB email. Robust and reasonably secure IMAP mailboxes sans administration headaches. No worries about third party email plugin breakage between version upgrades. While this method adds complexity it's not too difficult to get set up once you understand some underlying concepts, moving pieces involved and what you're targeting. It also serves as a stepping stone to building out your own email infrastructure should you decide this stuff is all just too much fun. Enjoy! o/
  • Setting up NodeBB with Mongo on Fedora 28

    Tutorials nodebb setup mongo fedora
    10
    0 Votes
    10 Posts
    4k Views
    Arief WijayaA
    @JaredBusch Thanks. Really appreciate it
  • How to Install NodeBB on Plesk v12.5.30

    Tutorials
    5
    4 Votes
    5 Posts
    6k Views
    ross03R
    Thank for sharing

Looks like your connection to NodeBB Community was lost, please wait while we try to reconnect.