Added the SCRIPT_FILENAME, PATH_INFO, and PATH_TRANSLATED parameter.

Maxim Dounin mdounin at mdounin.ru
Mon Sep 20 15:35:16 UTC 2021


Hello!

On Sat, Sep 18, 2021 at 07:19:24PM +0200, Robin Richtsfeld wrote:

> # HG changeset patch
> # User Robin Richtsfeld <robin.richtsfeld at gmail.com>
> # Date 1631984576 -7200
> #      Sat Sep 18 19:02:56 2021 +0200
> # Node ID 16927168a7b5712422021887f4a788e93d850159
> # Parent  97cf8284fd19b30169231e43831e7787baba72f2
> Added the SCRIPT_FILENAME, PATH_INFO, and PATH_TRANSLATED parameter.
> 
> For reference see the official PHP FastCGI Example:
> https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/
> 
> *diff -r 97cf8284fd19 -r 16927168a7b5 conf/fastcgi.conf*
> --- a/conf/fastcgi.conf Fri Sep 10 12:59:22 2021 +0300
> +++ b/conf/fastcgi.conf Sat Sep 18 19:02:56 2021 +0200
> @@ -6,6 +6,8 @@
>  fastcgi_param  CONTENT_LENGTH     $content_length;
> 
>  fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
> +fastcgi_param  PATH_INFO          $fastcgi_path_info;
> +fastcgi_param  PATH_TRANSLATED    $document_root$fastcgi_path_info;
>  fastcgi_param  REQUEST_URI        $request_uri;
>  fastcgi_param  DOCUMENT_URI       $document_uri;
>  fastcgi_param  DOCUMENT_ROOT      $document_root;
> *diff -r 97cf8284fd19 -r 16927168a7b5 conf/fastcgi_params*
> --- a/conf/fastcgi_params       Fri Sep 10 12:59:22 2021 +0300
> +++ b/conf/fastcgi_params       Sat Sep 18 19:02:56 2021 +0200
> @@ -1,10 +1,13 @@
> 
> +fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
>  fastcgi_param  QUERY_STRING       $query_string;
>  fastcgi_param  REQUEST_METHOD     $request_method;
>  fastcgi_param  CONTENT_TYPE       $content_type;
>  fastcgi_param  CONTENT_LENGTH     $content_length;
> 
>  fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
> +fastcgi_param  PATH_INFO          $fastcgi_path_info;
> +fastcgi_param  PATH_TRANSLATED    $document_root$fastcgi_path_info;
>  fastcgi_param  REQUEST_URI        $request_uri;
>  fastcgi_param  DOCUMENT_URI       $document_uri;
>  fastcgi_param  DOCUMENT_ROOT      $document_root;

Thanks for the patch, but no.
In no particular order:

- The wiki is not something official, it's user-contributed 
  content with mostly arbitrary quality, use it with caution.  
  Official documentation is available at nginx.org/docs/.

- The fastcgi_params file lacks SCRIPT_FILENAME intentionally.  If 
  you are using PHP and want to set it to 
  $document_root$fastcgi_script_name (which is not always the case), 
  you can use fastcgi.conf file.  In contrast, fastcgi_params can
  be used when you want to set SCRIPT_FILENAME to something 
  different, for example, to use a specific directory (see 
  nginx.conf for an example, 
  http://hg.nginx.org/nginx/file/tip/conf/nginx.conf#l63).

- PATH_INFO is, similarly, to be set explicitly when you've 
  configured nginx to provide one, see 
  http://nginx.org/r/fastcgi_split_path_info.

- PATH_TRANSLATED is implementation-defined, and nginx does not 
  try to define it.  If you want to use it, it is up to your 
  specific environment to set it to something.

Hope this helps.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list