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

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!

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.

Install LetsEncrypt SSL on multiple docker apps using the same domain

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.

Remote HTTP Endpoint to Docker Application

I have a demo application running perfectly on my local environment. However, I would like to run the same application remotely by giving it a HTTP endpoint. My goal is to test the performance of the application.
How to give a HTTP endpoint to any multi container docker application?
The following is the Github repository link for the demo application
https://github.com/LonareAman/BankCQRS.git
Use docker-compose and handle containers based on what you need
One of your containers should be web server like nginx. And then bind your machine port to your nginx like 80:80
Then handle your containers in nginx and make a proxy to them
You can find some samples in https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/

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 ?

How to publish a web site running in a docker container on production?

I have a web application running in a docker container on production server. Now I need to make API requests to this application. So, I have two possibilities:
1) Link a domain
2) Make requests directly by IP
I'm using a cloud server for that. In my previous experience I linked the domain to a folder. But now I don't know how to link the domain to a running container on ip_addr:port.
I found this link
https://docs.docker.com/v17.12/datacenter/ucp/2.2/guides/user/services/use-domain-names-to-access-services/
but it's for docker enterprice. Using of that is impossible for the moment.
To expose a docker application to the public without using compose or other orchestration tools like Kubernetes, you can use the docker run -p hostPort:containerPort option to expose your container port. Make sure your application is listening on 0.0.0.0:[container port] inside your container. To access the service externally, you would use the host's IP, and the port that the container port has been mapped to.
See more here
If you want to link to a domain, you can update your DNS records to point your domain to your host IP address.
Hope this helps!
Best way is to use kubernetes because it will ease many operations. But docker-compose can also be used.
If you want to simply deploy using docker it can be done by mapping hostPort to containerPort.

Resources