My domains are:
Dev Server: dev.bookshelf.sun-asterisk.ph (already has a certificate)
Staging Server: stage.bookshelf.sun-asterisk.ph
I ran this command: docker-compose up -d (staging)
It produced this output:
When I click the “Advanced” button, it redirects to my page but it is marked as “Not Secure” and that the certificate is invalid. It looks like it’s calling my dev server’s certificate.
My web server is (include version): nginx:1.15-alpine (Used as image in docker)
The operating system my web server runs on is (include version): CentOS Linux 7 (Core)
My hosting provider, if applicable, is: dotPH
I can login to a root shell on my machine (yes or no, or I don’t know): yes
The version of my client is (e.g. output of certbot --version or certbot-auto --version if you’re using Certbot): I'm using certbot as an image in docker
(4) And lastly, I ran the file init-letsencrypt.sh using the following command: sudo init-letsencrypt.sh
Addition:
I only added the dev.bookshelf.sun-asterisk.ph in the domain list because the configuration is inside the dev project folder. If I add the stage.bookshelf.sun-asterisk.ph in the domains, I get the wrong output:
I can only access stage.bookshelf.sun-asterisk.ph when the dev server if running up (docker-compose up -d).
The contents of the stage.bookshelf.sun-asterisk.ph is wrong. It’s using the same db as the dev server.
I’m wondering if I should create one certificate for both domains or create one for each.
Thank you for providing those scripts and configs. You may have better success using the following as replacements for your nginx container. The benefit of this is that you can easily run an arbitrary number of vhosts (dev, staging, etc) behind a single nginx container and give them each certificates.
nginx-proxy sets up a container running nginx and docker-gen. docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.
letsencrypt-nginx-proxy-companion is a lightweight companion container for the nginx-proxy. It allows the creation/renewal of Let’s Encrypt certificates automatically.
If you don’t want to check those out, I’d try a distinct nginx+app for both dev and staging. You may even be able to template this meaning you pass in an environment variable and docker would start nginx+dev_app, nginx+staging_app, or nginx+whatever_app.