<p><a href="https://github.com/Plykiya/Docker-Nginx-PHP-MySQL-PHPMyAdmin-Gitlab/blob/master/README.md" rel="nofollow noreferrer">Answered my own question, documented my steps on my Github repo.</a></p>

<p>Recap:</p>

<p>Add Nginx config to desired domains:</p>

<pre><code>location ~ /.well-known/acme-challenge {
        allow all;
        try_files $uri $uri/ /index.php;
    }
</code></pre>

<p>Use certbot staging to try out test certificates before running the real deal.</p>

<pre><code>sudo docker run -it --rm -v /some/place/to/save/letsencrypt:/etc/letsencrypt -v /some/place/to/save/lib:/var/lib/letsencrypt -v /some/place/to/have/html:/data/letsencrypt certbot/certbot certonly --webroot --register-unsafely-without-email --agree-tos --webroot-path=/data/letsencrypt --staging -d example.com
</code></pre>

<p>Run the real thing once ready</p>

<pre><code>sudo docker run -it --rm --v /some/place/to/save/letsencrypt:/etc/letsencrypt -v /some/place/to/save/lib:/var/lib/letsencrypt -v /some/place/to/have/html:/data/letsencrypt certbot/certbot certonly --webroot --email someemail@account.com
</code></pre>

<p>And then add in Nginx configs redirecting from http to https with ssl cert locations, updating nginx in docker-compose.yml to have access to certs. Go a tiny bit more in-depth about it in my repo</p>

CC BY-SA 4.0
2020-01-27T06:12:31.150Z
2020-01-27T06:12:31.150Z
Plykiya
<p>I went through one of the <a href="https://blog.linuxserver.io/2019/04/25/letsencrypt-nginx-starter-guide/#whataresslcerts" rel="nofollow noreferrer">guides that linuxserver.io</a> published to get started learning about how to setup the SSL encryption.  I was able to use their guide to use my own images and get up and running Nginx with an SSL cert for my site.</p>

<p>Automating it into a build workflow can be a challenge if you are not using a static IP.  Additionally, if you need to be able to accept external web traffic you will need to work with however controls your organizations firewall.</p>

CC BY-SA 4.0
2020-01-26T23:26:54.817Z
Seems like they use their own version of letsencrypt (which I'm trying to avoid, in the case they ever stop updating it or something...)

I was able to figure out how to use the regular certbot/certbot docker image to get my certs
Plykiya
CC BY-SA 4.0
2020-01-27T03:06:49.937Z
@Plykiya awesome!  Can you post your solution as the accepted answer?
Wesley Rolnick
CC BY-SA 4.0
2020-01-27T05:22:23.047Z
Can do, actually hadn't finished it yet. Had got the certs, not the nginx config. Now I have both and I'm confident in writing about it
Plykiya
CC BY-SA 4.0
2020-01-24T17:24:22.003Z
2020-01-24T17:24:22.003Z
Wesley Rolnick
<p>Title says it all I guess. I didn't even know what Ubuntu/Nginx/Docker/etc was a week ago but I've managed to set up Docker/Docker Compose, PHP-FPM, PHPMyAdmin + Gitlab on a reverse proxy through Nginx with somewhat difficulty. <a href="https://github.com/Plykiya/Docker-Nginx-PHP-MySQL-PHPMyAdmin-Gitlab" rel="nofollow noreferrer">My Github repo documenting my steps</a>.</p>

<p>Basically managed to do everything I wanted to do set-up wise. Last step is setting up SSL certs for my site. It wasn't as straightforward as I was hoping, I haven't been able to find any clear guides on what to do regarding setting up Cerbot and having it on automatic renewal through a docker container. Lot of the shorter tutorials seem to use custom Certbot docker images which I'm not sure why they're different, or they have custom shell scripts that make dummy certs and delete them for some reason. The <a href="https://hub.docker.com/r/certbot/certbot/" rel="nofollow noreferrer">Certbot docker hub</a> page is kind of devoid of any official instructions as well...</p>

<p>Any pointers or instructions would be extremely appreciated, thanks.</p>

<docker><nginx><certbot>
How do I set up certbot, with Nginx, both in a Docker container?
Plykiya
# How do I set up certbot, with Nginx, both in a Docker container?

(Asked by: username_0 on 2020-01-23)

Title says it all I guess. I didn't even know what Ubuntu/Nginx/Docker/etc was a week ago but I've managed to set up Docker/Docker Compose, PHP-FPM, PHPMyAdmin + Gitlab on a reverse proxy through Nginx with somewhat difficulty. [My Github repo documenting my steps](https://github.com/username_0/Docker-Nginx-PHP-MySQL-PHPMyAdmin-Gitlab).

Basically managed to do everything I wanted to do set-up wise. Last step is setting up SSL certs for my site. It wasn't as straightforward as I was hoping, I haven't been able to find any clear guides on what to do regarding setting up Cerbot and having it on automatic renewal through a docker container. Lot of the shorter tutorials seem to use custom Certbot docker images which I'm not sure why they're different, or they have custom shell scripts that make dummy certs and delete them for some reason. The [Certbot docker hub](https://hub.docker.com/r/certbot/certbot/) page is kind of devoid of any official instructions as well...

Any pointers or instructions would be extremely appreciated, thanks.

**Tags:** docker, nginx, certbot


---

## 2 answers

### Answer by username_0 on 2020-01-27. Score: 1 | Accepted answer

Answered my own question, documented my steps on my Github repo.
Recap:
Add Nginx config to desired domains:
location ~ /.well-known/acme-challenge {
        allow all;
        try_files $uri $uri/ /index.php;
    }

Use certbot staging to try out test certificates before running the real deal.
sudo docker run -it --rm -v /some/place/to/save/letsencrypt:/etc/letsencrypt -v /some/place/to/save/lib:/var/lib/letsencrypt -v /some/place/to/have/html:/data/letsencrypt certbot/certbot certonly --webroot --register-unsafely-without-email --agree-tos --webroot-path=/data/letsencrypt --staging -d example.com

Run the real thing once ready
sudo docker run -it --rm --v /some/place/to/save/letsencrypt:/etc/letsencrypt -v /some/place/to/save/lib:/var/lib/letsencrypt -v /some/place/to/have/html:/data/letsencrypt certbot/certbot certonly --webroot --email someemail@account.com

And then add in Nginx configs redirecting from http to https with ssl cert locations, updating nginx in docker-compose.yml to have access to certs. Go a tiny bit more in-depth about it in my repo


---

### Answer by username_1 on 2020-01-24. Score: 0

I went through one of the [guides that linuxserver.io](https://blog.linuxserver.io/2019/04/25/letsencrypt-nginx-starter-guide/#whataresslcerts) published to get started learning about how to setup the SSL encryption. I was able to use their guide to use my own images and get up and running Nginx with an SSL cert for my site.

Automating it into a build workflow can be a challenge if you are not using a static IP. Additionally, if you need to be able to accept external web traffic you will need to work with however controls your organizations firewall.

> **Comments:**
> **username_0**: Seems like they use their own version of letsencrypt (which I'm trying to avoid, in the case they ever stop updating it or something...)  I was able to figure out how to use the regular certbot/certbot docker image to get my certs  
> **username_1**: @username_0 awesome!  Can you post your solution as the accepted answer?  
> **username_0**: Can do, actually hadn't finished it yet. Had got the certs, not the nginx config. Now I have both and I'm confident in writing about it  

---

