[PATCH] implement a $location variable
António P. P. Almeida
appa at perusio.net
Fri Jan 4 02:10:38 UTC 2013
On 4 Jan 2013 02h58 CET, appa at perusio.net wrote:
> On 4 Jan 2013 02h22 CET, david at gwynne.id.au wrote:
>
>> here's a diff that provides $location for use in not regex location
>> blocks.
>>
>> we're using it to provide easy to use mass hosting of drupals:
>>
>> xdlg at argon nginx$ cat drupal-controller.conf
>> root /var/www/apps/drupal;
>> try_files /index.php =404;
>> include fastcgi_params;
>> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
>> fastcgi_param SCRIPT_NAME $location$fastcgi_script_name;
>> fastcgi_intercept_errors on;
>> fastcgi_pass localhost:9000;
>>
>> which is used in server blocks like this:
>>
>> server {
>> listen 80;
>> server_name www.example.com;
>>
>> location / { include drupal-controller.conf; }
>> location /foo { include drupal-controller.conf; }
>> location /bar { include drupal-controller.conf; }
>> location /baz { include drupal-controller.conf; }
>> }
>>
>> i cannot otherwise find a nice way to use the locations name as a
>> parameter without specifying the value as a variable again within
>> the location.
>
> I fail to see the need for a $location variable in a Drupal Nginx
> config. Can you elaborate why? The multiple inclusion is only needed
> if you redefine any of the fastcgi_param(s) in each location.
>
> Have you each site installed in a subdir? Is that the case?
>
>
> I think this will probably work in your case:
>
> location ~ ^(<current_location_base>[^/]*)/.*$ { include
> drupal-controller.conf; fastcgi_param SCRIPT_NAME
> $current_location_base/$fastcgi_script_name; }
Oops. Wrong regex. Rather:
location / {
include drupal-controller.conf;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
location ~ ^(/(<current_location_base>[^/]*).*$ {
include drupal-controller.conf;
fastcgi_param SCRIPT_NAME $current_location_base$fastcgi_script_name;
}
}
--- appa
More information about the nginx-devel
mailing list