Install LetsEncrypt SSL on multiple docker apps using the same domain - docker

I have deployed multiple docker containers on my CentOS machine and managing them with portainer.
containers are accessible via the same domain e.g.
container 1: example.com:80
container 2: example.com:6666
container 3: example.com:5083
and so on..
Now I want to use LetsEncrypt SSL for all of my container apps using the same domain (without subdomains).
I have been using nginxproxymanager (container app) to do my reverse proxy settings. Right now I am only able to use only one container (running on port 80) with SSL.
I am new to docker stuff and need help.

Related

Setting up nginx and ssl in docker (Asp .Net API in VPS)

I want to deploy api service (asp .net) to VPS.
What is at the moment:
VPS ubuntu 22.10
Container api service with open port http.
Container mongodb.
Network bridge for communication between these containers.
Volume for storing mongodb collections.
Configured dns subdomain, which translates to ip VPS.
What I want:
To add nginx.
To add ssl (Let's Encrypt with certbot).
I don't want to use docker compose because I want to understand how things works.
I'm not strong in terminology, but perhaps what I want to do is called an open nginx proxy.
Please tell me if I understand correctly what I need to do.
Nginx:
To run a separate nginx container.
To add the nginx configuration to the docker volume.
To add nginx to the bridge network (close ports on the api container, open ports on the nginx container)
To set up nginx location configs to work internally through the network bridge.
SSL:
On the VPS machine (not in the docker container) to install and run certbot
To enabled automatic certificate renewal
I'm not sure where I need to run certbot. On vps machine or in nginx docker container.
I don't know how to configure nginx to work through the bridge.

HTTPS All the Docker Container in one domain? - Let's Encrypt

I have domain called example.com which routed to 123.12.123.12 server.
And this is docker server so docker containers are like
123.12.123.12:1201
123.12.123.12:1202
123.12.123.12:1203
I am accessing this containers like
http://example.com:1201
http://example.com:1202
http://example.com:1203
But my project is webapp using microphone so i need all my docker container secured with SSL. Projects developed with Node.js
Is there any solutions? Thanks!

How to make a chain of nginx proxies using nginx docker containers with each docker having different IP?

I have a django app. In front of that I want to setup 3 nginx proxies (docker containers) in local (MacOS) like:
browser-->proxy1-->proxy2-->proxy3-->(gunicorn):django-app
I have to check some IP related thing in my django app. So when I am logging the x_forwarded_for header in my django app I am getting it as: 'X-Forwarded-For': '172.17.0.1, 172.17.0.1, 172.17.0.1'
I want to give each of my nginx proxy container a different static IP. How to do that. What docker command I need to use ?

Run two nginx instance using docker on same Machine

I have two separate sites behind two separate nginx hosted on separate VPS using docker.
When I tried to have both nginx on the same VPS server as separate docker container, it doesn't work. The running container is overwritten with the newer one.
How can I host both nginx instance on same docker machine? Both redirecting to separate proxy_pass app but the nginx port are same, i.e. 80 & 443.
If you want to have 2 nginx container, both listening to the same port, you can use Docker in swarm mode. It has a built in load balancer which redirect the load to both of them. (note that in this case, both nginx instances must come from the same image)
Just use your current docker-compose file, but deploy it in the swarm mode.

SSL Certificate for Multiple Docker Containers

I Have multiple Docker containers exposing their respective ports which I am bringing up using docker-compose, I have a service which is running on port 80.
I need to add SSL Certificate for all those Containers, Such that the application running on port 80 will be https
You can either keep certificate on a reverse proxy or propagate through service configuration tools - which one depends on your infrastructure. One example might be vault

Resources