Welcome! Log In Create A New Profile

Advanced

Пробелмы с ограничением доступа к файлам по паролю

Posted by unikum 
Прописываю в конфиге доступ к папке по паролю (/private в конфиге ниже). Если запрашивать папки или несуществующие адреса, запрос на пароль выдаётся. Но если запрашивать существующие файлы, доступ получается без запроса пароля. Что я делаю не так? Например, можно попасть на страницу, введя https://$host/private/video/index.php или скачать файл http://$host/private/video/video.mp4 без запроса пароля.

Конфиг:

user http;
worker_processes 1;

timer_resolution 100ms;
worker_rlimit_nofile 8192;

error_log logs/error.log;

events {
worker_connections 1024;
use epoll;
}

http {
include 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 logs/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;

server_tokens off;

keepalive_timeout 65;

gzip on;
gzip_disable "msie6";
gzip_comp_level 9;
gzip_http_version 1.0;

server {
listen 80;
listen 443 default ssl;
server_name localhost;

charset utf-8;

#access_log logs/$host.access.log main;

ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/cert.key;

ssl_session_timeout 5m;
ssl_verify_client off;

ssl_protocols SSLv3 TLSv1;
ssl_ciphers AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;
ssl_prefer_server_ciphers on;

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

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/http/;
}

location ~ \.php$ {
try_files $uri =404;
root html;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

location ~ /\.ht { access_log off; deny all; }
location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|m4v|mp4|mkv|avi)$ {
access_log off;
expires max;
}
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
location ~ /private {
auth_basic "Access closed.";
auth_basic_user_file htpasswd;
index index.html index.htm index.php;
if ( $scheme = "http" ) {
rewrite ^/(.*)$ https://$host/$1 permanent;
}

}
location /public {
autoindex on;
if ( $scheme = "https" ) {
rewrite ^/(.*)$ http://$host/$1 permanent;
}
}

}
}



Edited 1 time(s). Last edit at 09/15/2011 03:53PM by unikum.
Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 239
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready