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


Есть web сервер который работает на стандартной связке nginx с php-fpm в docker. Единственное что меня немного сбивает(далеко не каждый день имею с ним дело) что в ОС есть два процесса nginx, один(worker process) работает от пользователя nginx, второй от root-a(master process)…


Процессы контейнера:


bash-5.0# ps aux
PID USER TIME COMMAND
1 root 0:00 {docker-entrypoi} /bin/bash /docker-entrypoint.sh
9 root 0:00 crond
10 root 0:13 tor -f /etc/tor/my-torrc
13 root 0:00 nginx: master process nginx -g daemon off;
15 nginx 0:00 nginx: worker process
16 root 0:02 php-fpm: master process (/usr/local/etc/php-fpm.conf)
17 www-data 0:00 php-fpm: pool www
18 www-data 0:00 php-fpm: pool www
1364 root 0:00 bash
1442 root 0:00 ps aux
bash-5.0#


Установил владельца и группу nginx, на все файлы дал даже права 700


bash-5.0# ls -la
total 20
drwxr-xr-x 1 root root 4096 Sep 25 21:55 .
drwxr-xr-x 1 root root 4096 Sep 25 21:56 ..
drwx------ 9 nginx nginx 4096 Sep 25 22:07 html
drwxr-xr-x 3 root root 4096 Sep 25 21:55 localhost

bash-5.0# ls -la ./html/
total 64
drwx------ 9 nginx nginx 4096 Sep 25 22:07 .
drwxr-xr-x 1 root root 4096 Sep 25 21:55 ..
-rwx------ 1 nginx nginx 340 Sep 25 21:47 authenticate.php
drwx------ 2 nginx nginx 4096 Sep 25 22:07 css
drwx------ 7 nginx nginx 4096 Sep 25 22:07 fonts
drwx------ 3 nginx nginx 4096 Sep 25 22:07 images
-rwx------ 1 nginx nginx 1665 Sep 25 21:47 index.php
drwx------ 2 nginx nginx 4096 Sep 25 22:07 js
-rwx------ 1 nginx nginx 5042 Sep 25 21:47 login.php
-rwx------ 1 nginx nginx 88 Sep 25 21:47 requirements.txt
-rwx------ 1 nginx nginx 1401 Sep 25 21:47 run.py
-rwx------ 1 nginx nginx 1725 Sep 25 21:47 send.py
drwx------ 2 nginx nginx 4096 Sep 25 22:07 sound
drwx------ 11 nginx nginx 4096 Sep 25 22:07 vendor



В начале моего index.php я подключаю другой скрипт, который проверяет авторизован юзер или нет:


<?php
ini_set('session.cookie_lifetime', 3000);
require_once('authenticate.php');
?>


Вот сам authenticate.php,
ps: т.е если сессии нет то редирект пользователя на скрипт авторизации login.php.


<?php
session_start();
if(empty($_SESSION["authenticated"]) || $_SESSION["authenticated"] != 'true') {
header('Location: login.php');
}

//выход
$destroySessionFlag = filter_input(INPUT_GET, 'destroySession');
if ($destroySessionFlag == 1) {
unset($_SESSION['authenticated']);
session_destroy();
header('Location: login.php');
}
?>


Сейчас при попытке входа, отрабатывает index.php дальше меня перебрасывает на login.php как и должно быть.. но я вижу сообщение(судя по всему не от web сервера)


«File not found.»


Хотя права на файлы одинаковые, владелец и группа тоже..
Любой вывод команд предоставлю оперативно.


Думаю совсем не лишним здесь будет и сам конфиг nginx-а)


worker_processes 1;
error_log stderr warn;
pid /run/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

# Define custom log format to include reponse times
log_format main_timed '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$request_time $upstream_response_time $pipe $upstream_cache_status';

access_log /dev/stdout main_timed;
error_log /dev/stderr notice;

keepalive_timeout 65;

# Write temporary files to /tmp so they can be created as a non-privileged user
client_body_temp_path /tmp/client_temp;
proxy_temp_path /tmp/proxy_temp_path;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;

# Default server definition
server {
listen [::]:8080 default_server;
listen 8080 default_server;
server_name _;

sendfile off;

root /var/www/html;
index index.php index.html;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.php
try_files $uri $uri/ /index.php?q=$uri&$args;
}

# Redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/lib/nginx/html;
}

# Pass the PHP scripts to PHP-FPM listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param sсript_FILENAME $document_root$fastcgi_sсript_name;
fastcgi_param sсript_NAME $fastcgi_sсript_name;
fastcgi_index index.php;
include fastcgi_params;
}

location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires 5d;
}

# Deny access to . files, for security
location ~ /\. {
log_not_found off;
deny all;
}

# Allow fpm ping and status from localhost
location ~ ^/(fpm-status|fpm-ping)$ {
access_log off;
allow 127.0.0.1;
deny all;
fastcgi_param sсript_FILENAME $document_root$fastcgi_sсript_name;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}

# Include other server configs
include /etc/nginx/conf.d/*.conf;
}









 , ,






URL записи