I am currently experimenting with Kubernetes and deploying immutable images that contain a PHP webapplication in a load balanced setup.
What I am reading is that both your PHP-FPM (obviously) and your NGINX (this is what puzzles me) need to contain your app (php) code?
Ideally i want to build a custom docker image for php-fpm that includes my app code. But doing the same for the nginx feels very inefficient?
Since nginx is 'just' a proxy to redirect php requests towards the php-fpm pods, i dont really see the need to have my app code in the nginx container also.
I was reading here: https://stackoverflow.com/a/44900924/4875368 This seems like a similar setup.
My ideal scenario is having an ingress (nginx) that points to the nginx proxy that then redirects towards the php-fpm (if it is a php request).
If i need to create custom images for both nginx & php-fpm, then it almost feels smarter to create one apache-php image?
All suggestions welcomed!
The nginx config that i am currently looking at looks like this
server {
listen 80;
index index.php index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/myprojectroot; <==== this is the one confusing me!
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
This one also seems conceptually related, but leaves me wondering on how to procedd nonetheless: https://stackoverflow.com/a/49496411/4875368