patternphpdockerMinor
Multi-container server of PHP apps with reverse proxy?
Viewed 0 times
proxycontainermultireversewithphpappsserver
Problem
I am going to deploy my app to production on VPS server, using Docker. My goal is stable version from latest tag at
Because this is an PHP application, container has own nginx+php set. I don't know how - if it's even possible (without Swoole in PHP etc.) to avoid this.
Problem is in resources - I see that each app container has own nginx instance, and server (VPS) must have global nginx, working as reverse proxy for containers.
Is there are any better way to archieve my goals?
Thanks!
example.com, and dev version from dev tag at dev.example.com.Because this is an PHP application, container has own nginx+php set. I don't know how - if it's even possible (without Swoole in PHP etc.) to avoid this.
Problem is in resources - I see that each app container has own nginx instance, and server (VPS) must have global nginx, working as reverse proxy for containers.
Is there are any better way to archieve my goals?
Thanks!
Solution
Problem is in resources - I see that each app container has own nginx instance, and server (VPS) must have global nginx, working as reverse proxy for containers.
Generally speaking yes, this is how this sort of thing goes. It's more of an issue for PHP than other languages because PHP doesn't really have a standalone application server, but instead is commonly deployed using php-fpm with nginx. Since php-fpm supports communication via TCP sockets, theoretically you could run only fpm in the containers and have nginx on the host talk to fpm across the Docker networking layer, but I haven't researched this option enough to be convinced it would work.
Docker makes the most sense when used within the context of an orchestration layer like Kubernetes. Rather than running several Docker containers manually or semi-manually on a particular host, you would schedule them with kubernetes and it would distribute them across its cluster of nodes - the specific machine that runs the container becomes irrelevant. The kubernetes service then provides you with an IP via kube-proxy that load-balances across the pods of that service.
Generally speaking yes, this is how this sort of thing goes. It's more of an issue for PHP than other languages because PHP doesn't really have a standalone application server, but instead is commonly deployed using php-fpm with nginx. Since php-fpm supports communication via TCP sockets, theoretically you could run only fpm in the containers and have nginx on the host talk to fpm across the Docker networking layer, but I haven't researched this option enough to be convinced it would work.
Docker makes the most sense when used within the context of an orchestration layer like Kubernetes. Rather than running several Docker containers manually or semi-manually on a particular host, you would schedule them with kubernetes and it would distribute them across its cluster of nodes - the specific machine that runs the container becomes irrelevant. The kubernetes service then provides you with an IP via kube-proxy that load-balances across the pods of that service.
Context
StackExchange DevOps Q#5336, answer score: 1
Revisions (0)
No revisions yet.