Docker (compose) httpd proxy request to php container “File not found.”

I’m trying to learn more and build a development docker stack separating the Apache server from the PHP using different containers.

Actually this is the test docker-compose.yml configuration:

services:
  webserver:
    image: httpd:latest
    ports:
      - "8002:80"
    volumes:
      - ./apache/conf:/usr/local/apache2/conf
      - ./src:/usr/local/apache2/htdocs
  php:
    image: php:fpm
    volumes:
      - ./src:/var/www/html

In ./src there are only 1 directory public within 2 files:

  • index.html (that works great)
  • index.php (that isn’t find by php container)

I previously download the “vanilla” httpd configuration and set it as volume for the webserver service.

I update the configuration to serve index.php before index.html:

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

And then add the proxy configuration to the php service:

# Proxy to PHP-FPM
<FilesMatch .*.php$>
    SetHandler "proxy:fcgi://php:9000"
</FilesMatch>

I’m sure that when i ask for localhost:8002/public/index.php the php service is call and works (files are visible in the php container).

If I test the same but using NXING it works without problem, but with apache I’m still stuck in it.

I don’t find any clear explain searching online; I’m miss configure what?

EDIT 1:

Before any ask, I have already enable:

  • LoadModule proxy_module modules/mod_proxy.so
  • LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so