Setting up HTTPS support with Let's Encrypt

@tgxworld Thanks for the link. If I make these changes, I’m assuming that the script won’t update the cert until renewal because it will see a valid certificate already installed. How do I force it to update?

Thanks.

1 Like

Run the issue command manually with FORCE=1 :slight_smile:

2 Likes

@tgxworld Thanks for the tip.

I didn’t implement the file changes in app.yml, partly because I wanted to keep the build as standard as much as possible.

However, using the info from that post and your tip on FORCE=1, I did the following (posted here just in case someone else wants to do the same):
./launcher enter app vi /etc/runit/1.d/install_ssl_cert sv stop nginx FORCE=1 /etc/runit/1.d/install_ssl_cert sv start nginx

In the edit of install_ssl_cert, I changed the first line (after #!/bin/bash) to:
LE_WORKING_DIR="/shared/letsencrypt" /shared/letsencrypt/le.sh issue no example.com www.example.com 4096

Checked the certificate after install and it is now complete with and without “www”.

Thanks for your help.

5 Likes

Additional note to noobs running CloudFlare DNS:

You need to enable Full SSL in CloudFlare settings, or your site won’t work.

Installation wen’t smoothly and running this now on my small side project. Giving it some more time to mature, before enabling on my big site.

Once again, great job guys!

7 Likes

Is it possible to (easily) change when the script agrees to renew the script?

At the moment, it looks like the cert renewal is about 9 days before it expires. In the meantime, Let’s Encrypt has sent me two reminder emails saying that the cert is going to expire.

I’d prefer to have the cert renewed as soon as it possibly can so that I only get the LE reminder emails if, for some reason, the renewal process has failed and I therefore need to investigate further.

Thanks.

3 Likes

On my Discourse server, the auto-renew cron job seems to be broken. I’ve grabbed a shell:

./launcher enter app

and then tried to run a renewal myself:

"/shared/letsencrypt"/acme.sh --home "/shared/letsencrypt" --renew-all
[Fri Sep  8 10:50:23 UTC 2017] Renew: 'community.hestiapi.com'
[Fri Sep  8 10:50:23 UTC 2017] Single domain='community.hestiapi.com'
[Fri Sep  8 10:50:23 UTC 2017] Getting domain auth token for each domain
[Fri Sep  8 10:50:23 UTC 2017] Getting webroot for domain='community.hestiapi.com'
[Fri Sep  8 10:50:23 UTC 2017] Getting new-authz for domain='community.hestiapi.com'
[Fri Sep  8 10:50:24 UTC 2017] The new-authz request is ok.
[Fri Sep  8 10:50:25 UTC 2017] Verifying:community.hestiapi.com
[Fri Sep  8 10:50:30 UTC 2017] community.hestiapi.com:Verify error:Invalid response from http://community.hestiapi.com/.well-known/acme-challenge/90IFUOXXSZSmX3O_qjSS-ijnnyFJXMC6ZWYNm-UnuSE: 
[Fri Sep  8 10:50:30 UTC 2017] Please check log file for more details: /shared/letsencrypt/acme.sh.log

Looking in the log (which is pretty huge, but I can paste if needed) it appears to be writing the token, and then failing anyway.

My cert expires tonight (but it’s not a huge deal, we only have a few users), so any advice is appreciated!

Of course, as soon as I post, I find the issue. My site only passes 443 to Discourse as other things run on 80 - and of course the renewal has to happen on 80… as soon as I added a vhost on 80 to handle .well-known, all was fine. Thanks anyway!

4 Likes

Do I need to add any 301 redirects to let Google know about the move from http to https? Or it happens automatically?

AFAIK it happens auto-magically. Discourse automatically takes care of the 301 redirects.

That’s why it is No-Brains-Required™. :grinning:

4 Likes

I just set up a site with Let’s Encrypt and Firefox is whining that it “does not supply ownership information”.

Screenshot from 2017-10-05 09-32-03

Screenshot from 2017-10-05 09-35-27

But, there’s nothing that can be done, as explained here: Adding Ownership Information? - Help - Let's Encrypt Community Support

we were using this set up in order to have https. but then as we turned off cloudflare, we got Your connection is not secure error. and an expiration date for the ssl certificate.

questions

  1. is the output effect of this howto document the same as this one: Advanced Setup Only: Allowing SSL / HTTPS for your Discourse Docker setup? I mean both of them seem to allow for https.

  2. what is about the expiration date of a ssl? nothing about an expiration date is reported in this howto.

I followed this guide after setting up a new discourse “one-click” droplet on Digital Ocean. Just wanted to say thanks, it worked perfectly. Pretty awesome that uncommenting a few lines and restarting gives you SSL for free!

11 Likes

Thanks, Greg. Turns out I only had 443 open to the world as well. Once I opened up 80, voila, I was able to renew the Let’s Encrypt Cert.

2 Likes

If we are using Cloudflare, can’t we use Let’s Encrypt? Is not there a way?

Yes, read this post.

2 Likes

I just enabled Let’s Encrypt and SSL appears to be working, but there is an error in the console I don’t understand, and don’t know whether it’s related to SSL. Link below.

Note, the error takes a minute or two before it appears in my console.

This is the error I get in chrome console:

9/t/morning-i-ll-check/19:1 Failed to load
https://forum.artsupia.org/message-bus/dc19be97c09544aaaf966d011ce76c86/poll?dlp=t:
Request header field X-CSRF-Token is not allowed by
Access-Control-Allow-Headers in preflight response.

Something’s triggering a CORS preflight, which shouldn’t be happening because it’s all on the same domain, right?

1 Like

Yes, all on the same domain. There aren’t any external links, only images that were uploaded, and later edited out. Social media is not set up.

I played around with this test thread quite a bit. There were two image uploads, which I later removed from the post. I also turned a post into a wiki, and then switched the wiki off again. Just wondering whether something got messed up with all the editing. The thread is only for learning how to edit posts. It can be deleted.

Any ideas how to trace the error?

@tgxworld, Is it sufficient to force https from Discourse web admin, or do I still need to do that from the command line, as shown in the original post above?
> admin → site settings → force https

Doing it from the web interface is the same thing.

2 Likes