markshust / docker-magento

Mark Shust's Docker Configuration for Magento
https://m.academy/courses/set-up-magento-2-development-environment-docker/
MIT License
2.54k stars 1k forks source link

Create central nginx proxy load balancer #243

Open markshust opened 4 years ago

markshust commented 4 years ago

The problem with the current setup is that you cannot have multiple instances of Magento running at the same time unless each of the services run on a separate port. This is not ideal and confusing.

Ideally, we want an Nginx load balancer to sit in front of everything. For example:

dm start will start this Nginx load balancer

We then need to "register" sites with the load balancer. For example dm register ~/Sites/mysite will register the site with the load balancer, as well as setup SSL. I was previously looking into and working with https://github.com/nginx-proxy/nginx-proxy -- this setup seemed to work fine for NodeJS apps, but it buckled around Magento's complex setup and when it came to running SSL.

It's possible this central nginx load balancer could become a project entirely on its own, as this is a common problem with all docker projects, not just docker-magento. We could use Kubernetes, but I'd like to keep things simple in local dev. I think a simple proxy which allows users to register and deregister sites with the load balancer, and automatically sets up SSL certs for mac & linux would be sufficient.

markshust commented 4 years ago

I was able to get nginx-proxy working with mkcert. This makes running multiple instances of Magento possible with local SSL.

Example repo at https://github.com/markshust/nginx-proxy-mkcert

walkwizus commented 3 years ago

Hi,

Maybe get inspired by this following solutions:

https://github.com/nginx-proxy/nginx-proxy https://github.com/nginx-proxy/docker-letsencrypt-nginx-proxy-companion

dirkreitz commented 3 years ago

for local development you might look into Minikube. Pretty interesting in my opinion, and the configuration could be easily transferred to Kubernetes later.

bap14 commented 2 years ago

You could also leverage a project like Traefik to provide reverse proxy to multiple projects, and the only addition to this one would be some docker-compose.yml configuration changes (or potentially a docker-compose.traefik.yml file). There are some complexities with this, but it's how I generally run my projects and it works fine.