自动开启http认证

写了个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;
 
}

发表评论

注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

:wink: :twisted: :roll: :oops: :mrgreen: :lol: :idea: :evil: :cry: :arrow: :?: :-| :-x :-o :-P :-D :-? :) :( :!: 8-O 8)

本文链接:https://twd2.me/archives/5216QrCode