Score:1

NGINX basic auth bypass IP address OR user agent

tr flag

How to set up bypass in Basic Authentication by IP address or user agent in NGINX. If I set it like this:

map $http_user_agent $auth {
    default on;
    "~curl" "off";
}

server  {
.......
satisfy any;
allow 1.2.3.4;
allow 5.6.7.8;
deny all;
auth_basic $auth;
auth_basic_user_file /etc/nginx/.htpasswd;
.....
}

Then when I enter from an address other than the whitelist with user agent curl, then I get 403.

Score:0
jp flag

Disabling auth_basic likely removes it from the satisfy rather than making it true.

You can achieve what you are attempting by adding yet another authorization scheme, auth_request.

For example:

map $http_user_agent $auth {
    "~curl"  1;
}

server {
    ...

    satisfy any;

    allow 1.2.3.4;
    allow 5.6.7.8;
    deny all;

    auth_basic "Password protected";
    auth_basic_user_file /etc/nginx/.htpasswd;

    auth_request /auth;
    location = /auth {
        internal;
        if ($auth) { return 200; }
        return 401;
    }

    ...
}
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.