Comments on Basic HTTP Authentication With Nginx

Basic HTTP Authentication With Nginx This tutorial shows how you can use basic HTTP authentication with Nginx to password-protect directories on your server or even a whole website. This is the Nginx equivalent to basic HTTP authentication on Apache with .htaccess/.htpasswd.

9 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: Anonymous

Your example doesn't work for files under /test/

 

By: Karl

Its easy.. just replace

location /test
with:
location ^~ /test 

By:

Hello Everybody,

I need some help ...
Currently I am allowing authentication to the /administrator folder by (and this working fine for me):

location /administrator {
<tmpl_var name='web_document_root_www_proxy'>
index index.html index.php;
auth_basic "Members Only";
auth_basic_user_file <tmpl_var name='stats_auth_passwd_file'>;
}

However, the problem with that is if a user installs say Joomla in a subfolder within root eg

/joomla/ then that setting does not take effect.

I would like to take effect to any administrator folder accessed via the web regardless of the folder level .

Ie,

www.domain.com/administrator
www.domain.com/joomla/administrator
www.domain.com/joomla/site2/administrator

and etc ..

ALL those should be authenticated based on my .htaccess file defined above.

Please advice me on how I can modify the above directive to support that ...

By: Virginie

Hello,

I tried this solution and it works well, but I put the path of a test directory's file (http://www.example.com/test/test.php), the prompt windows doesn't show.

Do you know how to make this rule recursive for all the test directory's content ?

Thanks :)

 

By: Anonymous

this is working :)

Can we add a logout buttion?

 

By: JeffA

Thanks - Simple password protecting was not working until I can across this. Works great!

By: Joseph

thank you very much. :D

By: epoch

you can enter username and password in the link of the page?

By: gacontapdi

Which pattern can check and authenticate for path ^~/test/~/*.zip. Please help me. I need to fix my website.