Score:0

Change the script path in an Apache proxy handler

sn flag

I'm developing my application with 2 containers: apache and php-fpm.

Apache serves requests, and delegates PHP execution to the php-fpm container in its vhost:

    <FilesMatch .php$>
        SetHandler "proxy:fcgi://myapp-php-fpm:9000"
    </FilesMatch>

The two containers share a single volume that contains the application code.

The location of that volume is different in each of the containers:

  • apache mounts the app code volume at /home/wwwdata/myapp
  • php-fpm mounts the app code volume at /var/task

How can I change the script path that Apache sends to the php-fpm container, so that it matches where the volume is mounted in the php-fpm container?


I can do this in nginx by setting SCRIPT_FILENAME and DOCUMENT_ROOT:

        location ~ ^/index\.php(/|$) {
          fastcgi_pass myapp-php-fpm:9000;
          fastcgi_split_path_info ^(.+\.php)(/.*)$;
          include fastcgi_params;

          fastcgi_param SCRIPT_FILENAME /var/task/$fastcgi_script_name;
          fastcgi_param DOCUMENT_ROOT /var/task;

          internal;
        }

but I haven't been able to replicate this behavior in Apache.

Score:0
sn flag

Use ProxyFCGISetEnvIf to set the SCRIPT_FILENAME:

    <FilesMatch .php$>
        ProxyFCGISetEnvIf "true" SCRIPT_FILENAME "/var/task%{reqenv:SCRIPT_NAME}"
        SetHandler "proxy:fcgi://myapp-php-fpm:9000"
    </FilesMatch>
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.