Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
php-fpm uses path info as script name

We have what is supposed to be a pretty standard setup of Apache+php-fpm, but when an URL includes path info after the script name something strange happens -- it treats the path info as a script name relative to the web root. Like this:

# cat foo.php
<?php print 'I am foo! PATH_INFO = "' . $_SERVER['PATH_INFO'] . '"; SCRIPT_NAME = "' . $_SERVER['SCRIPT_NAME'] . '"; PHP_SELF = "' . $_SERVER['PHP_SELF'] . '"' ?>
# cat bar.php
<?php print 'I am bar! PATH_INFO = "' . $_SERVER['PATH_INFO'] . '"; SCRIPT_NAME = "' . $_SERVER['SCRIPT_NAME'] . '"; PHP_SELF = "' . $_SERVER['PHP_SELF'] . '"' ?>
# curl -kw\\n https://localhost/xxx/foo.php
I am foo! PATH_INFO = ""; SCRIPT_NAME = "/xxx/foo.php"; PHP_SELF = "/xxx/foo.php"
# curl -kw\\n https://localhost/xxx/bar.php
I am bar! PATH_INFO = ""; SCRIPT_NAME = "/xxx/bar.php"; PHP_SELF = "/xxx/bar.php"
# curl -kw\\n https://localhost/xxx/foo.php/xxx/bar.php
I am bar! PATH_INFO = "/xxx/bar.php"; SCRIPT_NAME = "/xxx/foo.php"; PHP_SELF = "/xxx/bar.php"

I was expecting the last one to give something like (correct me if I'm wrong):

I am foo! PATH_INFO = "/xxx/bar.php"; SCRIPT_NAME = "/xxx/foo.php"; PHP_SELF = "/xxx/foo.php/xxx/bar.php"

We have the following in /etc/httpd/conf.d/php-fpm.conf:

<IfModule proxy_fcgi_module>
    # Enable http authorization headers
    <IfModule setenvif_module>
    SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>

    <FilesMatch ".+\.ph(p[3457]?|t|tml)$">
        SetHandler "proxy:fcgi://localhost:9000"
    </FilesMatch>
    <FilesMatch ".+\.phps$">
        # Deny access to raw php sources by default
        # To re-enable it's recommended to enable access to the files
        # only in specific virtual host or directory
        Require all denied
    </FilesMatch>
    # Deny access to files without filename (e.g. '.php')
    <FilesMatch "^\.ph(p[3457]?|t|tml|ps)$">
        Require all denied
    </FilesMatch>
</IfModule>

Apache version 2.4.6 and php71-php-fpm-7.1.33. We have an application that expects the 'normal' behaviour, how can we get it with php-fpm?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda