NGINX и скачивание файлов.

Т
На сайте с 05.06.2010
Offline
49
4689

Прошу не смеяться. Это мой первый dedicated сервер и я не слишком специалист по администрированию и настройке. Хватит лирики. К сути проблемы.

Появилась необходимость сделать простой файловый хостинг. Работает все на Nginx и PHP-FPM. Все хорошо, но при скачивании появилась странная проблема, которую силами гугла не получилось решить.

Проблема: когда начинаешь скачивание файла к себе на ПК, то секунду 30-40 не получается нажимать на другие ссылки сайта, т.е либо очень медленно открываются, либо 504 ошибка. Грешил, что сервак ложиться, не справляется, но у меня Intel Xeon W3520 2.66 GHz+ 16GB DDR3 ECC. Bandwidth 250 Mbps и в статистике нагрузки все норм. Если одновременно открыть другой браузер и попробовать нажимать на ссылки, то все нормально переродится, без лагов и 504.

Прошу помощи, направить в верном пути меня. Надеюсь, что понятно суть проблемы обрисовал. Ниже приложу конфиги.

nginx.conf


user www-data;
worker_processes auto;

error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
multi_accept on;
use epoll;
}


http {

include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
client_header_buffer_size 1k;
client_body_buffer_size 2k;
client_max_body_size 500m;
large_client_header_buffers 4 8k;
send_timeout 10;
keepalive_timeout 20 20;
reset_timedout_connection on;
server_tokens off;
server_name_in_redirect off;
server_names_hash_max_size 512;
server_names_hash_bucket_size 512;

open_file_cache max=20000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors off;

gzip on;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/vhosts/*/*.conf;
server {
server_name localhost;
disable_symlinks if_not_owner;
include /etc/nginx/vhosts-includes/*.conf;
location @fallback {
error_log /dev/null crit;
proxy_pass http://127.0.0.1:8080;
proxy_redirect http://127.0.0.1:8080 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
access_log off ;
}
listen 80;
}
}

Конфигурационные файлы WWW-домена

server {

server_name givemeapp.ru www.givemeapp.ru;
listen 94.23.1.116:80 default_server;
charset off;
index index.php;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/givemeapp.ru/*.conf;
access_log /var/www/httpd-logs/givemeapp.ru.access.log;
error_log /var/www/httpd-logs/givemeapp.ru.error.log notice;
set $root_path /var/www/givemeapp/data/www/givemeapp.ru;
root $root_path;
autoindex off;



location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass unix:/var/www/php-fpm/givemeapp.sock;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f support@givemeapp.ru";
include fastcgi_params;
fastcgi_param PHP_VALUE "upload_max_filesize=150M; post_max_size=150M";
directio 200m;
expires max;
limit_rate 150K;
client_max_body_size 300m;
fastcgi_connect_timeout 900;
fastcgi_read_timeout 900;
fastcgi_send_timeout 900;

}


#download files
location /files {
rewrite ^/files/([a-z0-9]+)\..*$ /files.php?key=$1;


}



gzip on;
gzip_comp_level 6;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
expires 7d;

}

error.log nginx

2017/02/03 15:25:15 [emerg] 17823#17823: "user" directive is not allowed here in /etc/nginx/vhosts/givemeapp/givemeapp.ru.conf:2

2017/02/03 15:25:41 [notice] 17873#17873: using the "epoll" event method
2017/02/03 15:25:41 [notice] 17873#17873: nginx/1.10.1
2017/02/03 15:25:41 [notice] 17873#17873: built by gcc 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2)
2017/02/03 15:25:41 [notice] 17873#17873: OS: Linux 3.14.32-xxxx-grs-ipv6-64
2017/02/03 15:25:41 [notice] 17873#17873: getrlimit(RLIMIT_NOFILE): 1024:4096
2017/02/03 15:25:41 [notice] 17874#17874: start worker processes
2017/02/03 15:25:41 [notice] 17874#17874: start worker process 17875
2017/02/03 15:25:41 [notice] 17874#17874: start worker process 17876
2017/02/03 15:25:41 [notice] 17874#17874: start worker process 17877
2017/02/03 15:25:41 [notice] 17874#17874: start worker process 17878
2017/02/03 15:25:41 [notice] 17874#17874: start worker process 17879
2017/02/03 15:25:41 [notice] 17874#17874: start worker process 17880
2017/02/03 15:25:41 [notice] 17874#17874: start worker process 17881
2017/02/03 15:25:41 [notice] 17874#17874: start worker process 17882
2017/02/03 15:25:44 [notice] 17874#17874: signal 15 (SIGTERM) received, exiting
2017/02/03 15:25:44 [notice] 17878#17878: exiting
2017/02/03 15:25:44 [notice] 17881#17881: exiting
2017/02/03 15:25:44 [notice] 17876#17876: exiting
2017/02/03 15:25:44 [notice] 17875#17875: exiting
2017/02/03 15:25:44 [notice] 17879#17879: exiting
2017/02/03 15:25:44 [notice] 17877#17877: exiting
2017/02/03 15:25:44 [notice] 17880#17880: exiting
2017/02/03 15:25:44 [notice] 17881#17881: exit
2017/02/03 15:25:44 [notice] 17875#17875: exit
2017/02/03 15:25:44 [notice] 17878#17878: exit
2017/02/03 15:25:44 [notice] 17876#17876: exit
2017/02/03 15:25:44 [notice] 17879#17879: exit
2017/02/03 15:25:44 [notice] 17877#17877: exit
2017/02/03 15:25:44 [notice] 17880#17880: exit
2017/02/03 15:25:44 [notice] 17882#17882: exiting
2017/02/03 15:25:44 [notice] 17882#17882: exit
2017/02/03 15:25:44 [notice] 17874#17874: signal 17 (SIGCHLD) received
2017/02/03 15:25:44 [notice] 17874#17874: worker process 17878 exited with code 0
2017/02/03 15:25:44 [notice] 17874#17874: signal 29 (SIGIO) received
2017/02/03 15:25:44 [notice] 17874#17874: signal 17 (SIGCHLD) received
2017/02/03 15:25:44 [notice] 17874#17874: worker process 17882 exited with code 0
2017/02/03 15:25:44 [notice] 17874#17874: signal 29 (SIGIO) received
2017/02/03 15:25:44 [notice] 17874#17874: signal 17 (SIGCHLD) received
2017/02/03 15:25:44 [notice] 17874#17874: worker process 17875 exited with code 0
2017/02/03 15:25:44 [notice] 17874#17874: worker process 17876 exited with code 0
2017/02/03 15:25:44 [notice] 17874#17874: worker process 17877 exited with code 0
2017/02/03 15:25:44 [notice] 17874#17874: worker process 17879 exited with code 0
2017/02/03 15:25:44 [notice] 17874#17874: worker process 17880 exited with code 0
2017/02/03 15:25:44 [notice] 17874#17874: worker process 17881 exited with code 0
2017/02/03 15:25:44 [notice] 17874#17874: exit
2017/02/03 15:25:44 [notice] 17962#17962: using the "epoll" event method
2017/02/03 15:25:44 [notice] 17962#17962: nginx/1.10.1
2017/02/03 15:25:44 [notice] 17962#17962: built by gcc 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2)
2017/02/03 15:25:44 [notice] 17962#17962: OS: Linux 3.14.32-xxxx-grs-ipv6-64
2017/02/03 15:25:44 [notice] 17962#17962: getrlimit(RLIMIT_NOFILE): 1024:4096
2017/02/03 15:25:44 [notice] 17963#17963: start worker processes
2017/02/03 15:25:44 [notice] 17963#17963: start worker process 17964
2017/02/03 15:25:44 [notice] 17963#17963: start worker process 17965
2017/02/03 15:25:44 [notice] 17963#17963: start worker process 17966
2017/02/03 15:25:44 [notice] 17963#17963: start worker process 17967
2017/02/03 15:25:44 [notice] 17963#17963: start worker process 17968
2017/02/03 15:25:44 [notice] 17963#17963: start worker process 17969
2017/02/03 15:25:44 [notice] 17963#17963: start worker process 17970
2017/02/03 15:25:44 [notice] 17963#17963: start worker process 17971
2017/02/03 15:25:57 [info] 17964#17964: *3 client closed connection while waiting for request, client: 81.211.25.78, server: 0.0.0.0:80
2017/02/03 15:25:57 [info] 17964#17964: *4 client closed connection while waiting for request, client: 81.211.25.78, server: 0.0.0.0:80
2017/02/03 15:25:57 [info] 17964#17964: *6 client closed connection while waiting for request, client: 81.211.25.78, server: 0.0.0.0:80
2017/02/03 15:25:57 [info] 17964#17964: *7 client closed connection while waiting for request, client: 81.211.25.78, server: 0.0.0.0:80
2017/02/03 15:27:37 [info] 17968#17968: *19 client closed connection while waiting for request, client: 81.211.25.78, server: 0.0.0.0:80
2017/02/03 15:27:37 [info] 17968#17968: *20 client closed connection while waiting for request, client: 81.211.25.78, server: 0.0.0.0:80
2017/02/03 15:27:37 [info] 17968#17968: *21 client closed connection while waiting for request, client: 81.211.25.78, server: 0.0.0.0:80
2017/02/03 15:29:47 [info] 17971#17971: *46 client closed connection while waiting for request, client: 81.211.25.78, server: 0.0.0.0:80
2017/02/03 15:29:47 [info] 17971#17971: *47 client closed connection while waiting for request, client: 81.211.25.78, server: 0.0.0.0:80
2017/02/03 15:29:47 [info] 17971#17971: *48 client closed connection while waiting for request, client: 81.211.25.78, server: 0.0.0.0:80
M
На сайте с 17.09.2016
Offline
124
#1

отдача файла видимо через php скрипт сделана?

Не напрямую с ФС

S
На сайте с 17.08.2008
Offline
114
#2

Сделайте так, что бы отдачей файлов занимался nginx без участия php.

L
На сайте с 10.02.2015
Offline
221
#3

Блокировка сессий в php скорее всего...

Изучайте:

X-Accel-Redirect

session_write_close()

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий