FAQ

Page Discussion Edit History

NginxHttpAuthBasicModule

Contents

Edit section: Synopsis Synopsis

You can use this module to protect your site or parts of it with username and password based on HTTP Basic Authentication.

Example configuration

location  /  {
  auth_basic            "Restricted";
  auth_basic_user_file  conf/htpasswd;
}

Edit section: Directives Directives

Edit section: auth_basic auth_basic

syntax: auth_basic [ text|off ]

default: auth_basic off

context: http, server, location, limit_except

This directive includes testing name and password with HTTP Basic Authentication. The assigned parameter is used as authentication realm. A value of "off" makes it possible to override the action for the inheritable from a lower-level directive.


Edit section: auth_basic_user_file auth_basic_user_file

syntax: auth_basic_user_file the_file

default: no

context: http, server, location, limit_except

This directive sets the htpasswd filename for the authentication realm. Since version 0.6.7 the filename path is relative to directory of nginx configuration file nginx.conf, but not to nginx prefix directory.

The format of file is the following:

user:pass
user2:pass2:comment
user3:pass3

Passwords must be encoded by function crypt(3). You can create the password file with the htpasswd program from Apache.


Edit section: References References

Original Documentation