다음 nginx 구성이 있습니다.이 구성에 기본 인증을 추가하고 싶습니다.기본 인증을 nginx 구성에 다시 쓰기로 추가 할 수 있습니까
upstream phpfcgi {
server 127.0.0.1:7777;
# server unix:/var/run/php5-fpm.sock; #for PHP-FPM running on UNIX socket
}
server{
listen 80;
server_name qu.abc.com;
root /home/qu/website/current/web;
location/{
# try to serve file directly, fallback to rewrite
try_files $uri @rewriteapp;
}
location @rewriteapp {
# rewrite all to app.php
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass phpfcgi;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
나는 편집이
location/{
# try to serve file directly, fallback to rewrite
auth_basic "Restricted";
auth_basic_user_file /home/qu/website/current/web/.htpassword;
try_files $uri @rewriteapp;
}
에 위치 블록을하지만이 사람은 재 작동하지 않습니다. 누군가 도움이 될 수 있습니다.
안녕하세요 @ PravinMishra 이미 적응하려고합니다. 내가 얻는 문제는 basic_auth에 대한 서버 검사 전에 재 작성이 완료된다는 것입니다. 그래서 basic_auth를 먼저 확인한 다음 다시 작성하여이 작업을 수행하는 방법이 필요합니다. 또는이를 수행 할 수있는 대안이있을 수 있습니다. –