server {
    listen       8080;
    server_name  localhost;

    #charset koi8-r;

    access_log  logs/8080.access.log  main;

    location / {
        auth_basic "Auth ^_^";
        auth_basic_user_file /var/www/auth/ngx_auth;  # 通过httpd-tools中的工具可生成

        alias /var/www/web/;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

}


备份地址: 【nginx配置auth鉴权页面