#настройки сервера
server {
listen 80;
listen [::]:80;
server_name datclub.tk www.datclub.tk;
rewrite ^/(.*)$ https://datclub.tk/$1 permanent;
}
server {
listen 80 ;
listen [::]:80 ;
listen 443 ssl;
server_name localhost datclub.tk;
client_max_body_size 500m;
root /var/www/localhost;
index index.php index.html index.htm index.nginx-debian.html;
location /stat {
stub_status;
}
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_read_timeout 666;
}
location ~ /\.ht {
deny all;
}
location /files { #здесь была ошибка указана лишняя директория files
root /var/www/localhost ; #/files так же должен присутствовать перенаправление
add_header Content-type application/octet-stream;
internal;
}
location /download/ # перенаправление на скрипт раздающий файлы
{rewrite ^/download/download.php?path=$1 last;}
}
пытаюсь вывести файл load.gif
<?php
$path = "load.gif";
//...
// Perform any required security checks, validation
// and/or stats accounting
//...
// And redirect user to internal location
header("Content-Type application/octet-stream");
header("X-Accel-Redirect: files/" . $path);
readfile("files/".$path);
?>
выдаёт ошибку 404 , как вывести файл из директории интернал?