写了个nginx配置文件, 对于有.user文件的目录(必须是根目录下面的一级子目录)自动开启http认证。
1 2 3 4 5 6 7 8 9 10 11 12 | location ~ /\.(.+)/?$ { return 403; } location ~ ^/(.+?)/ { set $onfoo off; if ( -f $document_root /$1/.user ) { set $onfoo "$1" ; } auth_basic $onfoo ; auth_basic_user_file $document_root /$1/.user; } |
发表评论