Password Protect a Directory: Difference between revisions
m Update to use H2 headers for better readability |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= Password Protect a Directory in Plesk = | == Password Protect a Directory in Plesk == | ||
{{Caution| | |||
Password protection can take '''up to 2 hours''' to go into effect as it requires an Apache restart. | Password protection can take '''up to 2 hours''' to go into effect as it requires an Apache restart. | ||
We recommend you ensure that password protection is in place before uploading any sensitive files. | We recommend you ensure that password protection is in place before uploading any sensitive files. | ||
}} | |||
= Login to Plesk = | == Login to Plesk == | ||
Navigate to: | Navigate to: | ||
'''Login > Plesk > Websites & Domains > [ domain ] > | '''Login > Plesk > Websites & Domains > [ domain ] > 'Password-Protected-Directories'''' | ||
= Add Protected Directory = | == Add Protected Directory == | ||
[[File:plesk-password-protected-directories.png]] | [[File:plesk-password-protected-directories.png]] | ||
Click the | Click the 'Add Protected Directory' button and enter the details below: | ||
* In the | * In the 'Directory name' field, enter the path, relative to your domain root directory, to the directory you want to protect. | ||
* Your domain root directory is | * Your domain root directory is 'httpdocs' (if you were transferred from the old cPanel it will be called 'public_html'). | ||
* The specified directory will be created if it does not already exist. | * The specified directory will be created if it does not already exist. | ||
* Optionally, add a directory title in the | * Optionally, add a directory title in the 'Title of the protected area' field. | ||
* Click the | * Click the 'Create' button. | ||
[[File:plesk-create-protected-directory.png]] | [[File:plesk-create-protected-directory.png]] | ||
You should see a confirmation message that says: | You should see a confirmation message that says: 'Protected directory / [directory] was successfully created'. | ||
[[File:plesk-protected-directory-created.png]] | [[File:plesk-protected-directory-created.png]] | ||
Line 30: | Line 32: | ||
The directory will appear in the list of your domain's protected directories. | The directory will appear in the list of your domain's protected directories. | ||
= Add User Permissions = | == Add User Permissions == | ||
To access the protected directory, it must have at least one user associated with it. To add a user, click on the directory name: | To access the protected directory, it must have at least one user associated with it. To add a user, click on the directory name: | ||
Line 36: | Line 38: | ||
[[File:plesk-protected-directories-list.png]] | [[File:plesk-protected-directories-list.png]] | ||
Click on the | Click on the 'Add User' button. | ||
[[File:plesk-protected-directories-add-user.png]] | [[File:plesk-protected-directories-add-user.png]] | ||
Enter a Username and Password for the new user, and click on the | Enter a Username and Password for the new user, and click on the 'Create' button. | ||
[[File:plesk-protected-directories-create-user.png]] | [[File:plesk-protected-directories-create-user.png]] | ||
You should see a confirmation message that says: | You should see a confirmation message that says: 'The protected directory user [username] was created'. | ||
[[File:plesk-protected-directories-user-created.png]] | [[File:plesk-protected-directories-user-created.png]] | ||
Line 50: | Line 52: | ||
The user will appear in the list of the protected directory's users. | The user will appear in the list of the protected directory's users. | ||
To add more users, click the | To add more users, click the 'Add User' button and repeat the above steps. To change the password of an existing user, click on the key image. | ||
[[File:plesk-protected-directories-list-of-users.png]] | [[File:plesk-protected-directories-list-of-users.png]] | ||
= Add File(s) to Protected Directory = | == Add File(s) to Protected Directory == | ||
Since directory listing is not enabled, there must be at least one file inside the password protected directory, or else a | Since directory listing is not enabled, there must be at least one file inside the password protected directory, or else a '403 Forbidden' error will result. | ||
Using Plesk's File Manager or your preferred method of [uploading files](../../management/uploading-files.md), navigate to | Using Plesk's File Manager or your preferred method of [uploading files](../../management/uploading-files.md), navigate to 'httpdocs/protected-files' (or 'public_html/protected-files' if you were transferred from the old cPanel), and add your file(s). | ||
[[File:plesk-access-protected-directory-file-manager.png]] | [[File:plesk-access-protected-directory-file-manager.png]] | ||
For testing purposes, you could create a file called | For testing purposes, you could create a file called 'test.html' and paste in the content below: | ||
<pre> | <pre> | ||
<!doctype html> | <!doctype html> | ||
<html lang="en"> | <html lang=="en"> | ||
<head> | <head> | ||
<meta charset="utf-8"> | <meta charset=="utf-8"> | ||
<title>My Protected File</title> | <title>My Protected File</title> | ||
</head> | </head> | ||
Line 77: | Line 79: | ||
</pre> | </pre> | ||
= Wait for Apache Restart = | == Wait for Apache Restart == | ||
{{Caution| | |||
Password protection can take '''up to 2 hours''' to go into effect as it requires an Apache restart. | Password protection can take '''up to 2 hours''' to go into effect as it requires an Apache restart. | ||
}} | |||
= Web Browser Access = | == Web Browser Access == | ||
Within '''up to 2 hours''' of password protection being activated on your directory, navigate to | Within '''up to 2 hours''' of password protection being activated on your directory, navigate to 'domain.helioho.st/protected-files/test.html' in your web browser. | ||
[[File:plesk-access-protected-directory-in-browser.png]] | [[File:plesk-access-protected-directory-in-browser.png]] | ||
= Enter Username and Password = | == Enter Username and Password == | ||
Enter the Username and Password you created, and once you are signed in successfully, you should see a message that says: | Enter the Username and Password you created, and once you are signed in successfully, you should see a message that says: 'HelioHost rules!'. | ||
[[File:plesk-access-protected-file-success.png]] | [[File:plesk-access-protected-file-success.png]] | ||
= Additional Guidance = | == Additional Guidance == | ||
This [https://docs.plesk.com/en-US/obsidian/customer-guide/websites-and-domains/restricting-access-to-content.65152/ Plesk article] contains extra details and a walkthrough video which may be helpful. | This [https://docs.plesk.com/en-US/obsidian/customer-guide/websites-and-domains/restricting-access-to-content.65152/ Plesk article] contains extra details and a walkthrough video which may be helpful. |
Latest revision as of 17:13, 17 January 2025
Password Protect a Directory in Plesk
Password protection can take up to 2 hours to go into effect as it requires an Apache restart. We recommend you ensure that password protection is in place before uploading any sensitive files.
Login to Plesk
Navigate to:
Login > Plesk > Websites & Domains > [ domain ] > 'Password-Protected-Directories'
Add Protected Directory
Click the 'Add Protected Directory' button and enter the details below:
- In the 'Directory name' field, enter the path, relative to your domain root directory, to the directory you want to protect.
- Your domain root directory is 'httpdocs' (if you were transferred from the old cPanel it will be called 'public_html').
- The specified directory will be created if it does not already exist.
- Optionally, add a directory title in the 'Title of the protected area' field.
- Click the 'Create' button.
You should see a confirmation message that says: 'Protected directory / [directory] was successfully created'.
The directory will appear in the list of your domain's protected directories.
Add User Permissions
To access the protected directory, it must have at least one user associated with it. To add a user, click on the directory name:
Click on the 'Add User' button.
Enter a Username and Password for the new user, and click on the 'Create' button.
You should see a confirmation message that says: 'The protected directory user [username] was created'.
The user will appear in the list of the protected directory's users.
To add more users, click the 'Add User' button and repeat the above steps. To change the password of an existing user, click on the key image.
Add File(s) to Protected Directory
Since directory listing is not enabled, there must be at least one file inside the password protected directory, or else a '403 Forbidden' error will result.
Using Plesk's File Manager or your preferred method of [uploading files](../../management/uploading-files.md), navigate to 'httpdocs/protected-files' (or 'public_html/protected-files' if you were transferred from the old cPanel), and add your file(s).
For testing purposes, you could create a file called 'test.html' and paste in the content below:
<!doctype html> <html lang=="en"> <head> <meta charset=="utf-8"> <title>My Protected File</title> </head> <body> HelioHost rules! </body> </html>
Wait for Apache Restart
Password protection can take up to 2 hours to go into effect as it requires an Apache restart.
Web Browser Access
Within up to 2 hours of password protection being activated on your directory, navigate to 'domain.helioho.st/protected-files/test.html' in your web browser.
Enter Username and Password
Enter the Username and Password you created, and once you are signed in successfully, you should see a message that says: 'HelioHost rules!'.
Additional Guidance
This Plesk article contains extra details and a walkthrough video which may be helpful.