Web Servers

Password Protect Directory/Directories. OpenLiteSpeed Servers

OpenLiteSpeed is a fantastic Web Server that provides the stability and security of LiteSpeed Web Server together with caching but for no license costs. It’s a much better alternative to web servers like Apache and NGINX. When using applications like cPanel, it’s as simple as a few clicks to password-protect a directory. When you password-protect a directory using OpenLiteSpeed, anyone accessing that directory from a browser will be asked to authenticate. Therefore, it’s a great way of securing applications on your website like phpMyAdmin.

Password Protect Directory/Directories OpenLiteSpeed

In these examples, we want to password-protect the entire https://db.first2host.co.uk subdomain. The subdomain is already resolving to our server. But you can also password-protect folders/directories in OpenLiteSpeed. Login to the OpenLiteSpeed control panel and navigate to the virtual host in question.

On the Security tab. At the bottom click the + symbol under Realm List. In the Realm Name field. Enter a name for your Realm.

  • In the User DB Location. Enter the below code block.
$SERVER_ROOT/conf/vhosts/$VH_NAME/htpasswd
  • In the Group DB Location field. Enter the below code block.
$SERVER_ROOT/conf/vhosts/$VH_NAME/htgroup

In your Web Server, click save on the top right. You will be asked to click the paths entered above to create them. So notice now that you can click on both of the URLs that have been created. Click the $SERVER_ROOT/conf/vhosts/$VH_NAME/htpasswd link.

Create Username & Password

On this page, you can now create users who will have access to the password-protected directory. Create a user and set a password by clicking the + symbol.

Click save to add the user and password to the database. So the next steps depend on what you are securing with a password. Choose the situation below that reflects what you are trying to achieve.

  1. You want to password-protect an entire subdomain or domain.
    • Navigate to the “Context” tab. Create a “Static” context. Set the following fields
      • URI = /
      • Location = Location to the files of the virtual host. Should be the same as Virtual Host Root on the “basic” tab
      • Realm = The name of the Realm you created above.
  2. You want to password-protect a directory/folder in OpenLiteSpeed.
    • Navigate to the “Context” tab. Create a “Static” context. Set the following fields.
      • URI = /folder (folder to password-protect)
      • Location = Location to the files of the virtual host. Should be the same as Virtual Host Root on the “basic” tab but include the folder specified in the URI field above.
      • Realm = The name of the Realm you created above.

Finally, restart OpenLiteSpeed and you will now be asked to enter a username and password to access the virtual host or directory. Give it a try at https://db.first2host.co.uk.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button