How to password protect a directory

  1. Setup webadmin console if you haven’t already:
  1. Go to Virtual Hosts->Example->Security
  2. In a new tab, go to Virtual Hosts->YOUR DOMAIN->Security
  3. Add a new entry for your domain
  4. Copy the Example for each field but tweak them to fit your domain
  5. Go to Virtual Hosts->Example->Context-> /protected/
  6. In a new tab, go to Virtual Hosts->YOUR DOMAIN->Context-> /protected/
  7. Copy the Example for each field but tweak them to fit your domain
  8. In your VPS, go to /usr/local/lsws/conf/vhosts/YOUR DOMAIN
  9. Type “nano htpasswd”
  10. Go to Htpasswd Generator - Create Htaccess .htpasswd file with all 5 Algorithms!, fill out the form and select “crypt” for Encryption Algorithm
  11. Enter the given user:hash into the htpasswd file then save and close
  12. Set permissions to the file by typing “chmod +rwx htpasswd”
  13. Done
1 Like

Thanks but;

Currently not working. i will user /admin/protected/
folder but i can’t solve to your tutorial. Maybe changed.

make sure you folder
/usr/local/lsws/conf/vhosts/YOUR DOMAIN

owned the user lsadm and group by nobody

also following folders

/usr/local/lsws/conf
/usr/local/lsws/conf/vhosts

else it will keep asking password and says the password is wrong always…

I know this thread is outdated but it’s the first link that showed up when looking for a tutorial to protect a directory in CyberPanel, I thought I would help if someone needs this, here’s a basic tutorial on how to do this simply: How to Password Protect OpenLiteSpeed with Basic Auth and Realms - YouTube

I hope this helps someone.

2 Likes