How to Host Multiple Docker Containers on a Single Server with Nginx Reverse Proxy?

  Рет қаралды 61,480

Bobby Iliev

Bobby Iliev

Күн бұрын

Пікірлер: 134
@yuvvrajkperson
@yuvvrajkperson 2 жыл бұрын
No beating around the bush, straight to the point, easy examples, and answering questions in the comments. You sir are amazing
@hostinggeek
@hostinggeek 5 ай бұрын
This is by far the best nginx proxy tutorial I've seen in many years of doing this. It should be the standard.
@brendang8610
@brendang8610 4 жыл бұрын
I have been stuck for so long trying to configure the server blocks for my docker droplet. For a beginner like me who until today hadn't even heard of a server block, this was so much more informative than the digital ocean documentation on setting up nginx!!
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Hey Brendan, no problem at all! Happy to hear that you've found this helpful!
@votem2105
@votem2105 9 күн бұрын
Even now this is a bangger of a tutorial. 10/10 would recommend. You saved me multiple days of studying.
@josephjwilk
@josephjwilk Жыл бұрын
Thank you so much for this. I have struggled with this, and with some tweaks to the firewall and certbot, it's finally working! Thank you again for the straightforward and uncomplicated directions.
@dayumnson9769
@dayumnson9769 4 жыл бұрын
Instantly subscribed, what a clear ans straigth forward tutroial. Thanks man!
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Thanks a lot! Appreciate that! 🙌
@tsivanathan
@tsivanathan 4 жыл бұрын
Simple and straight to the point, thanks a lot sir!!!!
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Thank you for the nice feedback!
@mamirazmi
@mamirazmi Жыл бұрын
Sorry i quite new to docker deployment, can i know how to make it ssl and https with 443
@shadyjeff12
@shadyjeff12 Жыл бұрын
Can you make a tutorial on how to apple letsencypt certificates to those domains?
@soufianeodf9125
@soufianeodf9125 3 жыл бұрын
how you can add ssl certificate for those subdomains ?
@bobbyiliev_
@bobbyiliev_ 2 жыл бұрын
You can do that with a free Let's Encrypt SSL and certbot: www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04
@adremides
@adremides 4 жыл бұрын
Why not run the reverse proxy on a container too?
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
That is a good point! Thanks!
@PabloBecerra
@PabloBecerra Жыл бұрын
Nice tutorial! Thank you! I was wondering if it's possible to do the same, but with php-fpm containers. Which would be the right configuration for nginx in this case?
@MarlonSena
@MarlonSena Жыл бұрын
Tks, Bobby! :)
@brandonb7979
@brandonb7979 2 жыл бұрын
Did you edit the default file any? Also subscribed, great video!
@bobbyiliev_
@bobbyiliev_ 2 жыл бұрын
Thank you! No, I just used the default Nginx config, but I had my subdomains pre configured to point to my server before the video
@zeerar
@zeerar 2 жыл бұрын
Best tutotrial
@bobbyiliev_
@bobbyiliev_ 2 жыл бұрын
Thank you!
@jimmyj.6792
@jimmyj.6792 4 жыл бұрын
Hi thanks for video but how to automate the creation of subdomain when creating a new docker image with port ? It’s a little bit sad to create manually this file for each feature that i want to deploy. Thanks for your answer 😀
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Hi, yes that is a good point! You could try using Docker Compose, or an automation tool like Ansible to automate the manual tasks.
@jimmyj.6792
@jimmyj.6792 4 жыл бұрын
Bobby Iliev how can i integrate it into a pipeline like Jenkins or gitlab ci ?
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
@@jimmyj.6792 I would recommend going through this tutorial here: www.digitalocean.com/community/tutorials/how-to-set-up-continuous-integration-pipelines-in-jenkins-on-ubuntu-16-04
@தியான்
@தியான் 4 жыл бұрын
Hi ,can you post cluster management on Docker container like 1 load balancing 2 reachable 3 not reachable ,how do health check
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
That is a good idea! I will put it in my todo list and might give it a try!
@GkmVlogs2019
@GkmVlogs2019 Жыл бұрын
How to access container without changing end point url... for example I have an web api. I will run my web api as 2 container like instance..I want to access.
@shanahjrsuping7344
@shanahjrsuping7344 4 жыл бұрын
Did you also create A records for these domains?
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Hi Shanah, Yes I had the DNS records all pre-configured.
@shanahjrsuping7344
@shanahjrsuping7344 4 жыл бұрын
@@bobbyiliev_ Thank you very much!
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
@@shanahjrsuping7344 No problem at all! Happy to help.
@vinodhreddy6227
@vinodhreddy6227 4 жыл бұрын
I have a issue... I have three Ubuntu servers and I have 12 microservices. One server I created 4 services. One server one compose I configured four services.. I run I'm able register eureka all servixes... Zull gateway I can able to access fst servers but remaining I'm not able to access based on serviceId... Can I tell me where I done mistake
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
Hello, If you run docker network inspect do you see all services inside that network?
@jhoanmartinezsilva2609
@jhoanmartinezsilva2609 Жыл бұрын
Are the domains registered? The nane of the file must be the same as the domain? Thanks a lot!
@FrankoMtz
@FrankoMtz Жыл бұрын
Hi, nginx its instaled on your "server" ? or its like an other container?, thanks for the tuto
@ThisIsmeIrving
@ThisIsmeIrving 4 жыл бұрын
does this works even if I'm using like 3 docker containers to run a single app with wordpress? I want to use nginx as a load balancer between the containers to run wordpress.
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Yep, this should work with 3 WordPress containers as well. You might have to add some extra proxy rules in the Nginx Server Blocks to make it work for WordPress
@AnanyaDasgupta-t5k
@AnanyaDasgupta-t5k 5 ай бұрын
I don't have domain name configured for my server. I am trying to achieve the same using public ip. Is that not possible?
@lifetillhope5733
@lifetillhope5733 2 жыл бұрын
what about if i use nginx server as a container. mean my app deploy on one container and i have second container called nginx how i configure my nginx container as a reverse proxy? hope you understand my question. kindly reply
@yongquanrao7398
@yongquanrao7398 2 жыл бұрын
this is really helpful. thanks for sharing.
@bobbyiliev_
@bobbyiliev_ 2 жыл бұрын
Glad it was helpful!
@aloktechie7981
@aloktechie7981 2 жыл бұрын
Thank you so much for the video. I have my intel NUC setup and i have domain name as well, do we need to also do port forwarding in router or Nginx will take care of it ?
@bobbyiliev_
@bobbyiliev_ 4 ай бұрын
In case that you are just getting started with Docker, I could suggest this free eBook here too: devdojo.com/bobbyiliev/free-introduction-to-docker-ebook
@MohammedAbdulatef
@MohammedAbdulatef 4 жыл бұрын
Thank you so much, I have learned a lot from you.
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
🙌🏽🙌🏽🙌🏽
@santiagoale6232
@santiagoale6232 Жыл бұрын
This video sir is just perfect, thank you
@juliokavege9772
@juliokavege9772 Жыл бұрын
Nice video that help me so much. But it seen the reverse proxy i configure doesn't work. It doesn't work unless i type the port of my app. My context is : I dockerize a laravel app with 3 services(app, db , webserver(which is nginx)) and it host on hostinger vps.
@adithyakannan23
@adithyakannan23 3 жыл бұрын
I need the docker to point a domain I have, How to go for that ?
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
Hi there, I setup A records for each subdomain name to point to the Droplet's IP address before the video. Here is how you could do that: www.digitalocean.com/docs/networking/dns/how-to/manage-records/
@aswanthbabu1202
@aswanthbabu1202 2 жыл бұрын
how did you enable the sub-domian feature can we configure this with out name server and local machine ?
@bobbyiliev_
@bobbyiliev_ 2 жыл бұрын
Hey! For the example I created the DNS records in my DNS zone beforehand, but you could use your hosts file on your local machine if it is just for testing too
@pavelh2518
@pavelh2518 4 жыл бұрын
You can also run nginx as a docker container right?
@abhinav.sharma
@abhinav.sharma 4 жыл бұрын
Yes
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Yes absolutely. It might be even better in some cases.
@jonnetg
@jonnetg 3 жыл бұрын
Thank you so much!! Excellent Example!
@bobbyiliev_
@bobbyiliev_ 2 жыл бұрын
Thank you! Happy to hear that it was helpful!
@Ashish447
@Ashish447 4 жыл бұрын
Hi, I ran into an issue while implementing this great solution. Let's say I run the Nginx server as a docker container and it remains up. Now I have a microservices container(dockerized), and is accessed via Nginx reverse proxy. In case when a microservice's container is down for sometime and then restarted, the Nginx throws an upstream error. The upstream error occurs even if the container is up and running. Would appreciate any solution for this issue
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Hi there! This sounds like an interesting setup! Indeed running the Nginx service in a Docker container sounds like a better approach in some cases. In your Nginx configuration, are you using the Docker container IPs for the `server_block`? It sounds like that the docker container IP changes and then the Nginx service is no longer able to connect to the upstream. If this is the case I could suggest 2 things: - Make sure to create a docker network and use the container names rather than the container IPs: www.digitalocean.com/community/questions/how-to-ping-docker-container-from-another-container-by-name - Make sure to specify a restart policy so that if a service crashes, it would be restarted again: www.digitalocean.com/community/questions/how-to-start-docker-containers-automatically-after-a-reboot Finally if none of this helps, I would recommend checking your container logs for some more information on what is wrong: docker logs container_id_here Hope that this helps!
@Ashish447
@Ashish447 4 жыл бұрын
​@@bobbyiliev_ Thanks for your response. I am referring to the containers through their container names. Digging deeper into this issue, looks like an issue not from Nginx. What I observed: I have two containers, one built on Phoenix-elixir, the other built on Flask-uWSGI. This upstream error doesnt occur when I tried stopping and restarting the phoenix container. The issue was specific to the flask container. This certainly seems to be an issue somewhere inside uWSGI. Will get back if i found a solution for this :)
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
@@Ashish447 Sounds like a plan! Let me know how it goes!
@Ashish447
@Ashish447 4 жыл бұрын
@@bobbyiliev_ sure!
@faisalabdi6350
@faisalabdi6350 4 жыл бұрын
i tried to follow this on a Centos vm, when i browse to docker1 url, it keeps taking me to welcome centos url page for somereason, i keep having to add the port number still even though i installed nginx
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Hi, it sounds like that the Nginx server block configuration that you have is not correct. Feel free to post a question on the DigitalOcean community forum and include your current configuration files: www.digitalocean.com/community/questions
@faisalabdi6350
@faisalabdi6350 4 жыл бұрын
@@bobbyiliev_ cool will do.. thanks for your help
@soufianeodf9125
@soufianeodf9125 3 жыл бұрын
Thanks for the video, really helped
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
Glad to hear it!
@meghnamishra6659
@meghnamishra6659 4 жыл бұрын
Hey if have two node Js file one for server and another for client who are communicating with same port how to create docker image for DAT?
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Hello, In this case I could suggest following the steps here on how to build a Node.js application with Docker: www.digitalocean.com/community/tutorials/how-to-build-a-node-js-application-with-docker
@Ombibulous_Bluegrass
@Ombibulous_Bluegrass 3 жыл бұрын
Great video, thanks
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
No problem at all! Happy to hear that it was helpful!
@kalitsiadischaritos4685
@kalitsiadischaritos4685 3 жыл бұрын
Why this way working only with Ubuntu ? I tried also with red hat / centOS, arch , open suse but no results .
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
Hi there, The approach is more or less the same, however of course there are some differences between the different Linux distros. For example to install Nginx on CetnOS you would use dnf or yum and not apt. You can follow the steps on how to setup Nginx server blocks on CentOS here: www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-on-centos-7
@kalitsiadischaritos4685
@kalitsiadischaritos4685 3 жыл бұрын
@@bobbyiliev_ nope is not that the case. I repeat everything again, all installations done properly. Everything working fine but when it comes to serve the app, only Ubuntu is able to serve it. All other distros serve default ngnix page. Really strange. Anyway could you make one step ahead and add the ssl certificate?
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
@@kalitsiadischaritos4685 Feel free to post a question on the DigitalOcean community forum here: www.digitalocean.com/community/questions Make sure to provide as much information as possible including the Nginx server block configuration that you are using.
@FASHIONmanTV1
@FASHIONmanTV1 2 жыл бұрын
Perfect
@bobbyiliev_
@bobbyiliev_ 2 жыл бұрын
Thanks!
8 ай бұрын
thank you so much for the video, hope this is not a stupid question , is this information in the video valid in 2024 ?
@vietnguyen6228
@vietnguyen6228 3 жыл бұрын
Thank you my friend!
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
No problem at all! Happy to hear that this was helpful!
@aravinddas1720
@aravinddas1720 3 жыл бұрын
Is this method same in the centos environment, if so I'm not getting the URL part could you share the docs I can refer to
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
The Nginx configuration should be the same, but the installation process and the location of the config directory is different. You can follow the steps on how to install Nginx on CentOS 7 here: www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7
@aravinddas1720
@aravinddas1720 3 жыл бұрын
@@bobbyiliev_ Bro, I thank you for writing me back, just cleared all the configuration, wanted to overcome an issue could you look into it error message:- nginx: [emerg] PEM_read_bio_X509_AUX("/root/ssl/rnddev.csr") failed (SSL: error:0909006C:PEM routines:get_name:no start line:Expecting: TRUSTED CERTIFICATE) nginx: configuration file /etc/nginx/nginx.conf test failed
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
@@aravinddas1720 it looks like that you've added an SSL certificate to the `/root/ssl` folder, I would recommend moving it to /etc/ssl/ instead and then updating the path in your configuration accordingly.
@aravinddas1720
@aravinddas1720 3 жыл бұрын
@@bobbyiliev_ Same error brother after moving to /etc/ssl/
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
@@aravinddas1720 What is the error that you get when running an Nginx config test with this command: sudo nginx -t
@natural8471
@natural8471 9 ай бұрын
Thanks ! It's very helpful
@djcaesar9114
@djcaesar9114 5 ай бұрын
The big problem is that you have to manage the ports, and it will be difficult with multiple projects having their own team.
@salarkamjoo3669
@salarkamjoo3669 Жыл бұрын
perfect tutorial !
@hanss2006
@hanss2006 2 жыл бұрын
Nice
@bobbyiliev_
@bobbyiliev_ 2 жыл бұрын
Thank you!
@jiazq
@jiazq 3 жыл бұрын
'-dit' option mean what? it's wired!
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
-d = Detached -i = Keep STDIN open even if not attached -t = Allocate a pseudo-tty
@zeerar
@zeerar 2 жыл бұрын
nice
@bobbyiliev_
@bobbyiliev_ 2 жыл бұрын
Thanks!
@CarlosWolfram
@CarlosWolfram 4 жыл бұрын
Me has cambiado la vida y mi hosting poniéndome limites por crear subdominios xD
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Hi there, there are a few things you could do in this case: * either use actual domain names for each Nginx server block * access the containers directly on the port * use 1 server block with multiple locations, for example, /app1 /app2 and etc Hope that this helps!
@georgez8506
@georgez8506 4 жыл бұрын
Zdravei moje li da me posuvetva6 kak moga pusna wordpress multisite on docker localhost .
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
Привет, тук има добър пример за това: github.com/pie-inc/docker-wordpress-multisite
@pdamiano
@pdamiano 4 жыл бұрын
what about the https ?
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
Hi Damiano, you can add SSL with certbot as described here: www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04
@தியான்
@தியான் 4 жыл бұрын
Nice 👍
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
No problem at all! Happy to hear that it helped! 🙌
@ugurserhattoy
@ugurserhattoy 3 жыл бұрын
Why do you need apache? So isn't nginx enough to do that? Apache + nginx might be sacrificing nginx efficiency... Sounds like running linux on a windows machine.
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
The Apache containers were used only for the demo. You of course have to change them with your own application like NodeJS or whatever you are running Inside the container.
@Halissonskalee
@Halissonskalee 4 жыл бұрын
Nice! tansks!
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
No problem! Thank you for the feedback!
@ibrahimoglu
@ibrahimoglu 3 жыл бұрын
👍
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
🙌
@HafeedElbekkaoui
@HafeedElbekkaoui 2 жыл бұрын
It's an httpd appache revers server not an Nginx one.
@bobbyiliev_
@bobbyiliev_ 2 жыл бұрын
Not really, it is an Nginx Reverse proxy, in this case the Apache httpd was just the backend service, but it could be anything
@sprintwithcarlos
@sprintwithcarlos 4 жыл бұрын
🙌🏽
@bobbyiliev_
@bobbyiliev_ 4 жыл бұрын
🙌🏽🙌🏽
@vetorial_data_custom
@vetorial_data_custom 3 жыл бұрын
0:44 6:58
@bobbyiliev_
@bobbyiliev_ 3 жыл бұрын
🙌
How to host multiple websites on Nginx
4:39
Abstract programmer
Рет қаралды 14 М.
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
NGINX Explained - What is Nginx
14:32
TechWorld with Nana
Рет қаралды 321 М.
How to Setup a Reverse Proxy on Home Network
28:15
Toasty Answers
Рет қаралды 72 М.
Spin up an Nginx Docker Container as a Load Balancer
7:44
Hussein Nasser
Рет қаралды 40 М.
The NGINX Crash Course
50:53
Laith Academy
Рет қаралды 502 М.
Run Multiple Site from one IP with  reverse proxy Nginx
7:45
Juan Nadal
Рет қаралды 108 М.
Manage multiple sites with Docker Compose and Traefik
8:35
Andrew Schmelyun
Рет қаралды 55 М.
How to Set Up an NGINX Reverse Proxy
9:50
Akamai Developer
Рет қаралды 281 М.
Reverse proxy nginx letsencrypt tutorial
17:12
Christian Lempa
Рет қаралды 125 М.
FREE Domain and SSL for Local Network | Nginx Proxy Manager on Docker - #13
16:22
Tech - The Lazy Automator
Рет қаралды 85 М.
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН