how to password protect a directory in an nginx website?

    • OMV 1.0
    • Resolved
    • how to password protect a directory in an nginx website?

      Hello OMV World. I'm afraid I'm new to OMV and also nginx, but I've not found solutions in the Guides or the other Forums. so here goes:

      I just installed OMV 1.19 and omv-extras. I'd like to password protect a directory in a website I created using the nginx plugin. What's the best way to create the necessary .htpasswd file? apt-cache search htpasswd on the OMV install points to installing apache2-utils and libapache-htpasswd-perl. Or is there a different and better way to do this?

      Thanks,
      Mike
    • Thank you subzero79, I guess I was afraid to install anything more into the openmediavault box, but I overcame that fear.

      For the record, here is what I did:

      (1) Added a location stanza to the server I created in /etc/nginx/sites-enabled/openmediavault-nginx:

      ...
      location /intranet/ {
      auth_basic "Restricted Access";
      auth_basic_user_file /etc/nginx/.htpasswd;
      }
      ...

      (2) Then installed apache2-utils, which gives me htpasswd:

      apt-get install apache2-utils

      (3) Then created the passwordfile with the password for restricted access:

      cd /etc/nginx
      htpasswd -b -c .htpasswd username password

      (4) restart nginx

      service nginx restart

      And it works (how do I mark this as resolved?). Maybe putting these steps here will help others, as certainly will pointing to the nginx documentation.

      Thanks
      Mike
    • There is no need to install httpasswd since they are plenty of
      web utilities to generate http passwords.

      You don't edit the nginx file directly. You add it through the webui. Otherwise is gonna get overwritten in any plugin change.
      New wiki
      chat support at #openmediavault@freenode IRC | Spanish & English | GMT+10
      telegram.me/openmediavault broadcast channel
      openmediavault discord server
    • Hi.

      Can you tell me how I do it within the webui?

      For example I want to deny ip-address 192.168.1.10 to my wordpress page. Within nginx plugin I have created my server including the pool to use wordpress. All works fine. So what do I have to put in in the options field to deny ip-addresses?

      Regards lulu

      PS: Got it. Thanks and closed!

      The post was edited 1 time, last by lulu99 ().