microsoft / azure-container-apps

Roadmap and issues for Azure Container Apps
MIT License
359 stars 29 forks source link

Feature Request: FastCGI protocol support in ingress #742

Open davidbarratt opened 1 year ago

davidbarratt commented 1 year ago

Is your feature request related to a problem? Please describe.
PHP Applications have to use Apache (slow startup?) or deploy two containers (Nginx + PHP-FPM). It's a pain to have to configure this correctly.

Describe the solution you'd like.
I would like it if the Container App Ingress supported the FastCGI protocol as a "target protocol" or "backend protocol". The nginx ingress controller for k8s already supports this.

Describe alternatives you've considered.

  1. If you want to run a single container, you have to use Apache's httpd
  2. If you want better performance, you have to run two containers, one with Nginx and the other with PHP-FPM.

Additional context.
The official Docker Image for PHP basically gives you the same choices:

This image contains Debian's Apache httpd in conjunction with PHP (as mod_php) and uses mpm_prefork by default.

OR

This variant contains PHP-FPM, which is a FastCGI implementation for PHP. See the PHP-FPM website for more information about PHP-FPM.

In order to use this image variant, some kind of reverse proxy (such as NGINX, Apache, or other tool which speaks the FastCGI protocol) will be required.

I should also note that other languages support FastCGI, so this is not specific to PHP.

torosent commented 1 year ago

Hi, We currently don't have plans to add native support for FastCGI but I added it to our features request backlog.

vienleidl commented 1 year ago

I've just experienced the same issue when a nginx container is not able to communicate with php container via port 9000 with fastcgi_pass php:9000; in the configuration.

anthonychu commented 1 year ago

@vienleidl how are your containers deployed? If they are multiple containers in the same app, I think you’ll need to update the config to fastcgi_pass 127.0.0.1:9000; as containers will communicate over localhost.

vienleidl commented 1 year ago

@vienleidl how are your containers deployed? If they are multiple containers in the same app, I think you’ll need to update the config to fastcgi_pass 127.0.0.1:9000; as containers will communicate over localhost.

Hi Anthony, they're not as multiple containers in the same Container App. I did migrate the current microservices on Azure Multi-Container App Services (Docker Compose) to ACA, each container is responsible for each service within the same Container App Environment. One of them is running NGINX as a reverse proxy for forwarding the requests to other containers, it works well. However, one of them is running PHP-FPM needs to be communicated with other container via FastCGI protocol. The log is like below fyi: 2023-07-12T04:04:00.167612848Z 2023/07/12 04:04:00 [error] 47#47: *51 upstream timed out (110: Operation timed out) while connecting to upstream, client: 100.100.0.46, server: , request: "GET /?doc=xxx&document=xxx HTTP/1.1", upstream: "fastcgi://100.100.143.220:9000", host: "xxx.internal.yellowisland-xxxxxxxx.westeurope.azurecontainerapps.io", referrer: "https://xxx.internal.yellowisland-xxxxxxxx.westeurope.azurecontainerapps.io/?doc=xxx&document=xxx

anthonychu commented 1 year ago

@vienleidl Can you share the configuration of the fast cgi app? Please confirm it has ingress enabled for TCP and target/external ports set to 9000.

vienleidl commented 3 months ago

@vienleidl Can you share the configuration of the fast cgi app? Please confirm it has ingress enabled for TCP and target/external ports set to 9000.

Hi Anthony, I've just tested again, now it works well when enabling an internal ingress with TCP and target/exposed port are set to 9000.