Доброго времени суток, линуксоиды.
В общем, имею web-сервер. NGINX+PHP-FPM+MySQLi+PostgreSQL. Ничего особенного... Конфиг писал лично, но со временем добавлялись все новые и новые «очень нужные моменты», в результате чего появилась проблема.
Проблема: после прогрузки веб-сайта не отображаются рандомные картинки - что-то прогружается, что-то - нет. Закономерности нет, сугобо случайно.
Вопрос: где я натупил?
nginx.conf
user nginx;
worker_processes 8;
worker_rlimit_nofile 8192;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
error_log /var/log/nginx/error.log crit;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
worker_aio_requests 32;
multi_accept on;
}
http {
server_tokens off;
include /etc/nginx/mime.types.conf;
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 buffer=16k;
open_file_cache max=200000 inactive=10s;
open_file_cache_valid 10s;
open_file_cache_min_uses 6;
open_file_cache_errors on;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_comp_level 7;
gzip_buffers 64 32k;
gzip_http_version 1.0;
gzip_types *;
gzip_proxied any;
limit_conn_zone $binary_remote_addr zone=addr:8m;
limit_conn_zone $server_name zone=perserver:8m;
limit_conn addr 32;
limit_conn perserver 256;
server_name_in_redirect on;
server_names_hash_bucket_size 32;
sendfile on;
keepalive_timeout 10;
keepalive_requests 10;
reset_timedout_connection on;
tcp_nopush on;
tcp_nodelay on;
# client_body_timeout 10;
# send_timeout 10;
ssl_protocols TLSv1.3 TLSv1.2;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA384;
ssl_ecdh_curve secp384r1;
ssl_session_tickets off;
# ssl_stapling on;
ssl_stapling_verify on;
resolver 1.1.1.1 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
add_header Strict-Transport-Security 'max-age=31536000; preload';
add_header X-Frame-Options "DENY";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
proxy_max_temp_file_size 0;
proxy_buffering off;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
map $sent_http_content_type $expires {
default off;
text/html epoch;
text/css max;
application/javascript max;
~img/ max;
}
fastcgi_cache_key "$scheme$request_method$host$request_uri$cookie_PHPSESSID";
fastcgi_cache_path /tmp/nginx_cache levels=1:2 keys_zone=fastcgicache:10m inactive=70m max_size=512m;
fastcgi_cache off;
fastcgi_cache_valid 200 60m;
# fastcgi_cache_bypass $no_cache;
# fastcgi_no_cache $no_cache;
server {
server_name _;
root /usr/share/html;
listen 80;
}
include /etc/nginx/sites-enabled/*.conf;
}
конфиг сайта
server {
set $pool "example.com";
set $main_dir "example.com";
set $root_dir "/home/www/";
set $php_version "5.6";
set $php_exec_sec "60";
set $subdomain "";
server_name example.com www.example.com;
root $root_dir$main_dir/htdocs;
listen 80;
listen 443 ssl http2;
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
return 444;
}
if ( -f /var/log/nginx/ban/$remote_addr ) {
return 403;
}
pagespeed off;
pagespeed FileCachePath /home/www/example.com/htdocs/engine/cache;
location /nginx_stat {
stub_status on;
}
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
client_max_body_size 1m;
client_body_buffer_size 1024k;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
access_log /home/www/example.com/log/nginx_access.log main buffer=16k;
error_log /home/www/example.com/log/nginx_error.log crit;
add_header cache-control "no-cahce, no-store, must-revalidate, max-age=0";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; preload";
rewrite "^/photos.html$" /index.php?do=mod_photogal last;
rewrite "^/hotline.html$" /index.php?do=hotline last;
rewrite "^/rules.html$" /index.php?do=rules last;
rewrite "^/statistics.html$" /index.php?do=stats last;
rewrite "^/addnews.html$" /index.php?do=addnews last;
# Передача запроса в FPM
location ~ \.php$ {
try_files $fastcgi_script_name =404;
if ( $host != "example.com" ) {
rewrite ^(.+)$ https://example.com$1 permanent;
}
if ($scheme !~ ^https$) {
rewrite ^(.+)$ https://$host$1 permanent;
}
include /etc/nginx/fastcgi_params.conf;
client_body_temp_path /home/www/example.com/tmp;
fastcgi_param PHP_ADMIN_VALUE " upload_tmp_dir=$root_dir$main_dir/tmp/upload
open_basedir=$root_dir$main_dir/htdocs:$root_dir$main_dir/log:$root_dir$main_dir/tmp/upload:$root_dir$main_dir/tmp/download
session.save_path=$root_dir$main_dir/tmp/session
error_log=$root_dir$main_dir/log/php_error.log
mail.log=$root_dir$main_dir/log/php_mail.log
upload_max_filesize = 8M
post_max_size = 8M
memory_limit=32M
max_input_time=$php_exec_sec
max_execution_time=$php_exec_sec
";
}
location ~* \.(jpg|jpeg|gif|png|pdf|rar|zip)$ {
gzip off;
aio on;
access_log off;
expires -1;
}
location ~* \.(txt|css|js|log)$ {
access_log off;
add_header gzip_compress_ratio $gzip_ratio;
expires max;
}
}