# Rigenerazione delle chiavi Let'sEncrypt da dietro nginx

**URL:** <https://meta.discourse.org/t/regenerating-letsencrypt-keys-from-behind-nginx/95884>\
**Category:** Self-hosting\
**Created:** [29 Agosto 2018, 1:57am UTC](https://meta.discourse.org/t/regenerating-letsencrypt-keys-from-behind-nginx/95884 "2018-08-29T01:57:11Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![mogu](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@mogu](https://meta.discourse.org/u/mogu)\
**Post date:** [29 Agosto 2018, 1:57am UTC](https://meta.discourse.org/t/regenerating-letsencrypt-keys-from-behind-nginx/95884/1 "2018-08-29T01:57:11Z")

</div>

I followed this excellent guide for running Discourse behind nginx: [Run other websites on the same machine as Discourse](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247)

It worked great. Unfortunately the SSL certificate (via LetsEncrypt) expired after 90 days, and I’m having trouble regenerating it. I tried deleting these two files:

```
/var/discourse/shared/standalone/ssl/forum.mysite.com.cer
/var/discourse/shared/standalone/ssl/forum.mysite.com.key

```

but now `sudo nginx -t` complains that they don’t exist, and I wasn’t sure how to regenerate them.

`launcher rebuild app` didn’t fix it at first. But I tried re-enabling these two entries in `app.yml`:

```yaml
- "templates/web.ssl.template.yml"
- "templates/web.letsencrypt.ssl.template.yml"

```

and running `./launcher rebuild app` did regenerate these files. Unfortunately, one of them is 0 bytes long:

```plaintext
$ ls -l /var/discourse/shared/standalone/ssl/
-rw-r--r-- 1 root root 424 Aug 28 21:09 dhparams.pem
-rw-r--r-- 1 root root 0 Aug 28 21:42 forum.mysite.com.cer
-rw------- 1 root root 3243 Aug 28 21:42 forum.mysite.com.key

```

which nginx is not happy with:

```plaintext
$ sudo nginx -t
nginx: [emerg] PEM_read_bio_X509_AUX("/var/discourse/shared/standalone/ssl/forum.mysite.com.cer") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: TRUSTED CERTIFICATE
nginx: configuration file /etc/nginx/nginx.conf test failed

```

Our site is down, so if there’s a quick fix to properly regenerate these certificate files, I’d like to hear it. In the long run, is there a better way to set up SSL than what I have here? Should I be using LetsEncrypt on the nginx layer rather than from within Discourse?

Thank you!

---

_[View the full topic](https://meta.discourse.org/t/regenerating-letsencrypt-keys-from-behind-nginx/95884)._
