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

  • 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!

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!