DiVeRsO
DiVeRsO

Reputation: 13

how can i set nginx to keep ask authentication everytime

i want to make a website with nginx for myself for fun and i was trying to add authentication to it. i added a user in /etc/nginx/.htpasswd. but its only one time asking me to type the password and when i refresh the page its not asking me again.here is my /etc/nginx/sites-enabled/default file.

        location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
            auth_basic "Restricted Content";
            auth_basic_user_file /etc/nginx/.htpasswd;
    }

Upvotes: 0

Views: 1560

Answers (1)

fabreg
fabreg

Reputation: 123

I'm not completely sure that is possibile, or at least, not natively. HTTP authentication information is stored on your browser cache, and should only be requested again if the authentication fails or it's from a different realm (in auth_basic "Restricted Content"; it's Restricted).

Upvotes: 1

Related Questions