How to secure a subdomain

Hello, I’m trying to add HTTP access authentication to certain subdomain of my site but I don’t know how to do that.

I want to add username and password for certain url.

This doesn’t work:

ee secure --auth

Thank you

I don’t understand: you say you want to protect a subdomain, but your examples show a folder.

Anyways, I’ll explain the basics, I think you’ll be able to solve your issue once you understand what you’ll be doing.

First you need to create a .htpasswd file. I suggest it to be in nginx/conf folder.

printf "$HTPASSWDUSER:$(openssl passwd -crypt $HTPASSWDPASS 2> /dev/null)\n" >> /var/www/

Now I suggest you to create a file named auth.conf in /var/www/ with the following content:

auth_basic "Restricted Area"
auth_basic_user_file /var/www/

That’s it.

You should test configuration in order to avoid errors, and reload Nginx:

nginx -t && service nginx reload

Yes, it’s a subfolder not a subdomain.

Thank you.

In such case, you should do the file /var/www/ look like:

location ~ ^/yourfolder {
    auth_basic "Restricted Area"
    auth_basic_user_file /var/www/