How do I password protect a directory on my server with cloudpanel
2026-05-13 14:43:15
#1

I am new to cloudpanel. I just switch over from using cpanel for many years. I am sorry if this question has been asked before. I searched and could not find my answer.

I want to password protect one directory on my server so that when it is trying to be accessed it will ask for a username and password.

There was an option for this in cpanel. I see there is not one in cloudpanel.

For example, I was to protect my genealogy directory at www/mysite.com/genealogy.

Is there some type of documentation that explains how to do this step by step for cloudpanel users?

2026-05-15 12:09:26
#2

CloudPanel does not include a built-in GUI option like cPanel’s “Directory Privacy” feature.However, you can protect a directory using Nginx Basic Authentication:

Step 1: Create a password file

sudo apt-get install apache2-utils
htpasswd -c /etc/nginx/.htpasswd myuser
(You will be prompted to set a password for "myuser".)

Step 2: Edit your site’s Nginx config (usually in /etc/nginx/sites-enabled/mysite.com.conf) and add:

location /genealogy {
    auth_basic "Restricted Area";
    auth_basic_user_file /etc/nginx/.htpasswd;
}

Step 3: Reload Nginx

sudo systemctl reload nginx

Result:

Now, when someone visits mysite.com/genealogy, they will be asked for the username and password you set.This is the recommended way to password-protect directories in CloudPanel.

Yazdığımız şeyler bizi temsil eder, Efendilik iyidir.
Please Login or Register.
Currently 1 people reading this topic. (1 guest(s))
Currently reading 0
Reacted 1
Rootali