nginx try_files & drupal
Vasiliy G Tolstov
v.tolstov at selfip.ru
Fri Oct 9 15:45:45 MSD 2009
В Птн, 09/10/2009 в 13:36 +0400, Igor Sysoev пишет:
> Такой вариант лучше:
>
> 1) идеологически,
> 2) немного быстрее - нет нового поиска location'а после rewrite'а и нет
> двух regex'ов - "rewrite ^/(.*)$" и "location ~ \.php$".
>
> В принципе, можно обойтись и без @drupal вообще:
> try_files $uri $uri/ /index.php?q=$uri&$args;
>
>
Странно, но с таким вариантов не работает теперь image_cache модуль:
первый атач - по конфигу вида:
1.conf (1.log)
второй по другому конфигу:
2.conf (2.log)
Есть ли какой-то вариант заставить try_files сработать и в этом случае?
--
Vasiliy G Tolstov <v.tolstov at selfip.ru>
Selfip.Ru
-------------- next part --------------
server {
listen 80;
server_name www.iul4a.ru;
root /home/iul4a/www/iul4a.ru;
access_log /home/iul4a/logs/iul4a.ru/access_log main;
error_log /home/iul4a/logs/iul4a.ru/error_log warn;
if ($http_host ~ "^blog.(.*)") {
set $name $1;
rewrite ^/(.*) http://$name/blog/$1;
}
if ($http_host ~ "^selfip.spb.ru") {
rewrite ^/(.*) http://selfip.ru/$1;
}
if ($http_host ~ "^www.(.*)") {
set $name $1;
rewrite ^/(.*) http://$name/$1;
}
location ~ /\.ht {
deny all;
break;
}
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {
expires 31d;
add_header Last-Modified: $date_gmt;
#break;
}
location "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$" {
deny all;
}
location ~ "^/(CHANGELOG|COPYRIGHT|INSTALL\.mysql|INSTALL\.pgsql|INSTALL|LICENSE|MAINTAINERS|UPGRADE)\.txt" {
deny all;
}
index index.php;
fastcgi_index index.php;
location / {
try_files $uri $uri/ @drupal;
}
location ~ \.php$ {
try_files $uri @drupal;
fastcgi_pass unix:/var/run/php/iul4a.ru;
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 SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
}
location @drupal {
fastcgi_pass unix:/var/run/php/iul4a.ru;
fastcgi_param QUERY_STRING q=$uri&$args;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.log
Type: text/x-log
Size: 24377 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx-ru/attachments/20091009/1726a8a3/attachment.bin>
-------------- next part --------------
server {
listen 80;
server_name www.iul4a.ru;
root /home/iul4a/www/iul4a.ru;
access_log /home/iul4a/logs/iul4a.ru/access_log main;
error_log /home/iul4a/logs/iul4a.ru/error_log debug;
if ($http_host ~ "^www.(.*)") {
set $name $1;
rewrite ^/(.*) http://$name/$1;
}
location ~ /\.ht {
deny all;
break;
}
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {
expires 31d;
add_header Last-Modified: $date_gmt;
#break;
}
location "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$" {
deny all;
}
location ~ "/backup" {
deny all;
}
location ~ "^/(CHANGELOG|COPYRIGHT|INSTALL\.mysql|INSTALL\.pgsql|INSTALL|LICENSE|MAINTAINERS|UPGRADE)\.txt" {
deny all;
}
if ( !-e $request_filename ) {
rewrite ^(.*)$ /index.php?q=$1 last;
break;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/iul4a.ru;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2.log
Type: text/x-log
Size: 64006 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx-ru/attachments/20091009/1726a8a3/attachment-0001.bin>
More information about the nginx-ru
mailing list