синтаксис: root путь;
умолчание: root html;
контекст: http, server, location, if в location
root /var/www/default;
location / {
if ($http_cookie ~ 'test') {
root /var/www/test;
}
try_files $uri $uri/ /index.html;
}
location / {
index index.php index.html index.htm;
try_files $uri $uri/ @php;
}
location ~ \.php$ {
fastcgi_pass php5-fpm-sock;
fastcgi_index /;
fastcgi_param SCRIPT_NAME index.php;
fastcgi_param SCRIPT_FILENAME $app_root/index.php;
fastcgi_param app-key $app_key;
include fastcgi_params;
}
location @php {
fastcgi_pass php5-fpm-sock;
fastcgi_index /;
fastcgi_param SCRIPT_NAME index.php;
fastcgi_param SCRIPT_FILENAME $app_root/index.php;
fastcgi_param QUERY_STRING q=$uri&$args;
include fastcgi_params;
}
location ~* ^/nginx-download/([a-z0-9\.\-]*)/(.*)$ {
resolver 127.0.0.1; # DNS сервер
set $srv $1;
set $fn $2;
proxy_set_header Host $srv;
proxy_set_header Referrer $srv;
proxy_set_header User-Agent 'User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2';
proxy_hide_header Content-Disposition;
proxy_pass http://$srv/$fn;
proxy_max_temp_file_size 0;
}