error_page and named locations

Jean-Philippe Moal skateinmars at skateinmars.net
Thu Dec 11 16:56:16 MSK 2008


Igor Sysoev a écrit :
>>>
>>> I'm going to implement the non_existant_request_file directive to use
>>> in similar configurations:
>>>
>>>     location ~\.php$ {
>>>         non_existant_request_file  @drupal;
>>>
>>>         fastcgi_pass  ..
>>>     }
>>>
>>> This directive test a request file existance before passing a request
>>> to fastcgi/proxy.
>>>
>>> Could someone suggest better name ?
>> Also I want to replace typcal mongrel configuration:
>>
>> with something like
>>
>>      location / {
>>          match  $request_filename
>>                 $request_filename/index.html
>>                 $request_filename.html;
>>                 @mongrel;
>>      }
>>
>> like "index" directive.
>>
>> Or
>>
>>          try    $request_filename
>>                 $request_filename/index.html
>>                 $request_filename.html
>>                 /some_fallback_url;
> 
> The single directive can be used for Mongrel type configuration:
> 
>       location / {
>           file_match  $uri  $uri/index.html  $uri.html
>                       @mongrel;
>       }
> 
>       location @mongrel {
>           ...
>       }
> 
> and Drupal/Joomla type configuration:
> 
>       location / {
>           file_match  $uri  @drupal;
>           # the same as
>           #    error_page  404 = @drupal; log_not_found off;
>       }
> 
>       location ~ \.php$ {
>           file_match  $uri  @drupal;
> 
>           fastcgi_pass   ...
>           fastcgi_param  SCRIPT_FILENAME /path/to$script_filename;
>       }
> 
>       location @drupal {
>           fastcgi_pass   ...
>           fastcgi_param  SCRIPT_FILENAME /path/to/index.php;
>       }
> 
> The file_match iterates parameters and changes URI to the first one
> that matches filesystem. An @name matches always and is used as fallback.
> All matches except fallback are handled in the same location context.
> 
> 

I think "try" is a good name for this feature (which will certainly be _really_
useful, thanks !).





More information about the nginx mailing list