I got a reminder from Redsift that my certificates are going to expire in a week. Usually discourse will renew the certificates well ahead of time. This time not so, before I start doing a rebuild (which is supposed to solve the issue), @Falco is there anything you want me to check and post back here to help get to the root of why the certificates did not renew?
The root certificate is ISRGX1 and here is the expiring certificate information:
But itās been over a day since I updated the forum software and the certificate doesnāt appear to have been updated yet. Itās got 5 days before it expires so it really needs to be renewed soon.
Iām on the Discouse stable branch if that makes a difference. Is it possible the endpoint fix hasnāt been backported?
We have had the same experience of SSL not renewing.
It would be great if someone could double check that web.ssl.template is behaving correctly on discourse-docker, it appeared to me that port 80 was not actually serving any /.well-known/ URLs used by Letās Encrypt, all URLs were forwarding to SSL including test files I manually placed into /var/www/discourse/public/.well-known/ . I had to edit /etc/nginx/conf.d/outlets/before-server/20-redirect-http-to-https.conf directly inside the app container.
Same here. I didnāt get a warning abount the certās expiration. Enterine the server and launching a rebuild /var/discourse % ./launcher rebuild did the trick.
In my testing on a vanilla nginx install (1.18.0 but I think itās the same for 1.26.3), an nginx config line return 301 https://thehostname$request_uri; outside of a location completely overrides any earlier location block before it, rather than being a catch-all. I believe /.well-known/ simply isnāt served on port 80 unless the 301 redirect is specifically for another location such as / at the end of the server block. Could be the same problem as this stackoverflow post?
Glad rebuild works, but since the cert had already renewed for me, I couldnāt confirm that a rebuild would allow the Letās Encrypt validation servers to get there if a cert had expired. Maybe a rebuild kicks off the cert renewal before that template line is in place or similar rather than fixing the templates, but Iām not able to confirm if thatās why rebuild gets the renewal to work.
I can confirm that letsencrypt renewal fails. Iāve been running a self-hosted Discourse install for years, and very strangely renewal failed for me two times in a row over the past couple of months. The second time was this morning, and so I started investigating.
First, return 301 https://${DISCOURSE_HOSTNAME}$request_uri; gets turned into return 301 https://<MY SERVER NAME> without a $request_uri at the end. I have verified on my self-hosted install, and also on a friendās self-hosted install that was set up in the past week. I donāt understand how Discourse template works, so I donāt know why it gets dropped.
Second, as @lessLost mentioned, the 301 redirect is outside of the location block. I believe a server level redirect overrides all location blocks. LetsEncrypt uses http for renewals. However, any attempt to curl -I http://YOUR_DOMAIN/.well-known/acme-challenge/test will return a 301 to https, instead of a 404 (which is expected behaviour; we want a 404 not a 301).
Iāve fixed this manually on my self-hosted install, but I expect any update will override my changes. Unfortunately I donāt understand the templates enough to submit a pull request @pfaffman ā or Iād do that too.
Edited to add:
I believe this is mistaken ā
Iām fairly certain LetsEncrypt uses http by default (for obvious reasons, if the cert is expired then it canāt renew!) But placing the 301 at the server block level forces all requests to 301 to https, which is inconsistent with this renewal strategy.
Edit 2: Evidence for the http renewal strategy, but you may also Google around to verify this.
This morning, roughly 10 minutes after I woke up, visited my forum, and realised the cert had expired again. (Rebuilding was what renewed the last time it expired on me ā roughly 3 months ago?)
I think that theyāve committed changes since then that have fixed this problem, but since it takes 3 months to find out, the jury is still out. You might set a reminder a couple weeks before the current cert expires.
My friendās new site install was from a week ago. Line 37 of the template above reads: return 301 https://${DISCOURSE_HOSTNAME}$request_uri; but in the Discourse Docker container, both her (and my) /etc/nginx/conf.d/outlets/before-server/20-redirect-http-to-https.conf reads return 301 https://<our_discourse_site>; Notice how $request_uri is stripped. Something is causing that to vanish! (I donāt know what).
I did a simulated forced renewal this morning as part of my investigation. It failed. I then changed /etc/nginx/conf.d/outlets/before-server/20-redirect-http-to-https.conf. It succeeded!
This is actually ok; Iāll just manually edit 20-redirect-http-to-https.conf every time I update Discourse. For those stumbling on this comment, the command to run is:
Iām not entirely sure what is causing this failure, but I know modifying the conf above fixes it. But Iāve also modified notifs so that letsencrypt renewals no longer fails silently ā so I can have some advanced warning. Just thought youād like to know!