![nginx 거부 및 허용 규칙이 작동하지 않습니다.](https://linux55.com/image/69276/nginx%20%EA%B1%B0%EB%B6%80%20%EB%B0%8F%20%ED%97%88%EC%9A%A9%20%EA%B7%9C%EC%B9%99%EC%9D%B4%20%EC%9E%91%EB%8F%99%ED%95%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
먼저, nginx.conf에 이것이 있습니다.
server {
listen 80;
root /home/user/files;
index index.php index.html index.htm;
server_name mydomain.com;
location / {
autoindex on;
}
#this option will allow auto index on video directory
location ~ ^/video {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
include /etc/nginx/conf.d/php;
autoindex on;
autoindex_exact_size on;
}
#only spesific ip allow to download files in video directory
location ~ ^/video/* {
autoindex off;
allow myip;
deny all;
}
}
것 같다허용하다규칙이 작동하지 않고 비디오 파일을 다운로드하려고 하면 여전히 403이 표시됩니다.
내 conf에 문제가 있나요?
답변1
location
같은 블록에 넣으세요 .
location /video/ {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
allow myip;
deny all;
include /etc/nginx/conf.d/php;
autoindex on;
autoindex_exact_size on;
}
location ~ regexp
간단한 정방향 일치만으로도 충분한 경로로 regexp match( )를 사용하고 동일한 위치에 대해 자동 인덱싱 켜기/끄기를 혼합하는 이유를 이해할 수 없습니다 .