среда, 20 мая 2020 г.

Nginx map $request_uri example

If I need to add http auth to special location I can use map

http block

map $request_uri $auth {
    /2.3.5/  "Authorization Required";
    default  "off";
}

server block

    auth_basic $auth;
    auth_basic_user_file /etc/nginx/.htpasswd;