nginxだとphp scriptファイルにbasci認証がかからないんで すけどー

映像配信

本ページは広告が含まれています。気になる広告をクリック頂けますと、サーバ運営費になります(^^

nginxでbasic認証をかける事は出来た。

https://www.techlive.tokyo/archives/1290

だけど、試したら、phpスクリプトには認証がかかってない。同じディレクトリにあるのに何で?

このサイトが参考になった。
http://stackoverflow.com/questions/4697010/nginx-auth-basic-and-php

以下のようにしたらphpスクリプトにもユーザ名・パスワードが聞かれるようになった。

location / {
root html;
index index.html index.htm index.php;
auth_basic "Hanako Bassic Test";
auth_basic_user_file "/usr/local/nginx/passwd/.htpasswd";
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

 

タイトルとURLをコピーしました