
도메인의 파일을 검색하기 전에 인증이 필요하도록 서버를 설정하려고 합니다. 그런데 placeholder.html
인증에 실패한 경우 사용자 지정 오류 페이지( )를 표시하고 싶습니다 .
아래 나열된 서버 구성을 시도했지만 브라우저가 무한 리디렉션 루프에 빠지게 됩니다(인증 창도 표시하지 않음). 누구든지 그것을 설명할 수 있나요? 이 문제를 어떻게 해결하시겠습니까?
server {
listen 80;
server_name example.com;
root /var/www/example.com;
index index.html index.htm;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/auth/example.com.auth;
error_page 401 placeholder.html;
location = placeholder.html {
auth_basic off;
}
location / {
try_files $uri $uri/ =404;
}
}
답변1
및 지시문 placeholder.html
앞에 슬래시를 추가해야 합니다 .location
error_page