Форум русскоязычного сообщества Ubuntu


Следите за новостями русскоязычного сообщества Ubuntu в Twitter-ленте @ubuntu_ru_loco

Автор Тема: Nginx+PHP-FPM и запрет доступа в каталоги к файлам *.php  (Прочитано 4980 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн avi9526

  • Автор темы
  • Активист
  • *
  • Сообщений: 618
  • ахтыжъёшкинкот
    • Просмотр профиля
    • Блог av9526
Мой конфиг «Nginx» /etc/nginx/sites-available/default:
server {
root /var/www;
index index.html index.htm;

# Make site accessible from http://localhost/
server_name ********** www.*********;

# Deny access to important files
# Deny access to important places of Dokuwiki (see https://www.dokuwiki.org/security#web_access_security)
# Deny access to .htaccess & .htpasswd files
location ~* /(\.ht.*|engine|inc|data|conf|bin|info|install|module|profile|po|sh|\..*sql|theme|tpl(.php)?|xtmpl)((/.*)?)$
{
deny all;
return 404;
}

location /
{
index index.php index.html index.htm;
}

location /repository/
{
autoindex on;
allow all;
# Nice looking index h5ai
index  /_h5ai/server/php/index.php;
}

location /ftp/
{
autoindex on;
allow all;
# Nice looking index h5ai
index  /_h5ai/server/php/index.php;
}

location /restricted/
{
auth_basic "Restricted";
auth_basic_user_file htpasswd;
}

location /doc/
{
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}

# Pass the PHP scripts to FastCGI server listening on TCP port or UNIX socket
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
location ~ ^(.+\.php)((/.+)?)$
{
# Edit php-fpm listening port in /etc/php5/fpm/pool.d/www.conf
# With php5-cgi alone (PHP listening on TCP port):
# fastcgi_pass 127.0.0.1:9000;
# With php5-fpm  (PHP listening on UNIX socket):
fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_split_path_info ^(.+\.php)(.*)$;

# Order is important - first must be "include fastcgi_params"

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param SERVER_ADMIN avi9526@*********;
fastcgi_param SERVER_SIGNATURE nginx/$nginx_version;

fastcgi_index index.php;
}

}
проблема в том, что доступ, например, к «www.example.com/rescticted» закрыт, но файл «www.example.com/rescticted/info.php» доступен. Точно так же с «www.example.com/doc/abracadabra». Доступа нет, но если попробовать «www.example.com/doc/abracadabra.php», то получаю сообщение «No input file specified.» (от PHP-FPM), т.е. доступ не заблокирован…

Как разрулить эту ситуацию (я не шарю особо эту тему).
« Последнее редактирование: 07 Декабря 2012, 19:22:49 от avi9526 »
Ubuntu 14.10

Оффлайн avi9526

  • Автор темы
  • Активист
  • *
  • Сообщений: 618
  • ахтыжъёшкинкот
    • Просмотр профиля
    • Блог av9526
- location "/restricted/"
+ location ^~ "/restricted/"
не прошло и недели как я прочитал оф. документацию )
wiki.nginx.org
« Последнее редактирование: 12 Декабря 2012, 17:54:38 от avi9526 »
Ubuntu 14.10

 

Страница сгенерирована за 0.016 секунд. Запросов: 21.