Hi Andreas,

Andreas Enge <[email protected]> writes:

> Hello,
>
> I would like to set up a web server with a password (only one user and
> the associated password), in the same way as the .htaccess file does for
> apache.
>
> When looking on the web, there are examples how to do this with Ubuntu etc.,
> by adding a file somewhere to /etc (with the hashed password) and editing a
> line in the configuration file.
>
> Does our nginx configuration allow us to do the same?

I do the same with my nginx configuration:

(nginx-server-configuration
      (listen '("443 ssl" "[::]:443 ssl"))
      (server-name (list "foo.org"))
      (root "/var/www/foo")
      (locations
       (list
        (nginx-location-configuration
         (uri "/")
         (body (list "index index.html;"
                     "auth_basic \"closed site\";"
                     ;; needs to be set manually
                     "auth_basic_user_file /etc/nginx/htpasswd;")))))
      (ssl-certificate ...)
      (ssl-certificate-key ...))

/etc/nginx/htpasswd may contain:
user:<hashed-pwd>

(I don't remember how to generate that hashed password.)

Clément

Reply via email to