nginx 配置auth basic使matomo访问统计接口,有时候我们A目录下有一些php程序,A目录下还有一个B文件夹,但是我们需要让外部访问B文件夹的一些文件,该怎样做呢?
|/www/html
|___ /www/html/matomo
server {
listen 443;
server_name www.example.com;
root /www/html;
auth_basic "Please input password";
auth_basic_user_file /usr/local/nginx/db/passwd.db;
index index.html index.htm index.php;
location /matomo {
#关闭顶级目录认证
auth_basic off;
location = /matomo/piwik.js {
#关闭piwik.js文件认证
auth_basic off;
}
#解析matomo.php文件
location = /matomo/matomo.php {
#关闭matomo.php文件认证
auth_basic off;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9001;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
location ~\.php$ {
root /var/www/html/;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9001;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}