How to Protect Page with Password in Apache, Nginx, WordPress, Hosting?

You might have a delicate web page that you simply need to password shield. That is also called primary authentication.

The excellent news is that it is potential, and it is tremendous simple.

Why shield the net web page with a password?

Properly, there may very well be many causes together with.

  • Accommodates delicate knowledge on the web page
  • The web page is not prepared but and you do not need to make it publicly seen, however share it with somebody

No matter it’s, let’s discover how one can shield.

Required

Let’s take an instance; I need to shield /shopper at lab.geekflare.com, which suggests if anybody has entry https://lab.geekflare.com/shopper should ask for a password.

Apache

Let’s begin with Apache first.

The very first thing we have to create is a password file the place all of the credentials might be saved. The file title could be .htpasswd and you may place it wherever on the server. I’ll create it beneath /and so forth/httpd/conf folder

  • You possibly can create the file with the contact command
contact /and so forth/httpd/conf/.htpasswd
  • Let’s add the consumer who would entry /shopper. Now we have to make use of htpasswd order for this.
htpasswd /and so forth/httpd/conf/.htpasswd geekflare
  • The final half, Geekflare, is the username. Change that with no matter you need and press Enter.
  • Enter the password and you will notice a affirmation that the consumer has been added.
[root@lab html]# htpasswd /and so forth/httpd/conf/.htpasswd geekflare
New password: 
Re-type new password: 
Including password for consumer geekflare
[root@lab html]#

In the event you hangover the file, you’ll discover that the password is saved in an encrypted format. It’s effectively!

[root@lab html]# cat /and so forth/httpd/conf/.htpasswd 
bestnich:$apr1$EHvl0Bc5$nh4u0w3.Cj3wzPT7XUXqW1
[root@lab html]#

Subsequent, we have to instruct Apache to guard the specified URI.

  • Modify the httpd.conf file or configuration file you utilize for the Apache occasion. I am utilizing the default set up, so I am utilizing /and so forth/httpd/conf/httpd.conf
  • Add the next someplace within the file
<Listing "/var/www/html/shopper">
Choices Indexes FollowSymLinks
AuthType Primary
AuthName "Protected Content material for Consumer"
AuthUserFile /and so forth/httpd/conf/.htpasswd
Require valid-user
</Listing>

In the event you’ve already achieved that /var/www/html/shopper Listing directive, then as an alternative of including a brand new part it is best to simply add the next to the present directive.

AuthType Primary
AuthName "Protected Content material"
AuthUserFile /and so forth/httpd/conf/.htpasswd
Require valid-user
  • Restart Apache
service httpd restart
  • Attempt to entry the /shopper web page and it ought to ask for a password.

  • Enter the credential you arrange earlier to view the content material.

Trendy .htaccess technique?

After all you may implement primary authentication through .htaccess file too. You continue to must generate credentials utilizing htpasswd as defined above. Whenever you’re achieved, you may add the next to the suitable folders .htaccess file.

AuthType Primary
AuthName "Protected Content material"
AuthUserFile /and so forth/httpd/conf/.htpasswd
Require valid-user

The nice factor is that you do not have to restart Apache.

Nginx

Let’s implement primary authentication in Nginx by following.

We are going to enlist the assistance of Apache Utils to generate the credentials. If the server doesn’t have Apache HTTP put in, you could set up the instruments individually as beneath. If you’re unsure, you may run htpasswd to see if it really works. If not, you understand you could set up it.

CentOS/RHEL 8

dnf set up httpd-tools

CentOS/RHEL 7

yum set up httpd-tools

ubuntu

apt-get set up apache2-utils
  • Let’s create the credentials, just like how we did in Apache.
htpasswd -c /and so forth/nginx/.htpasswd chandan
  • Do not forget to exchange Chandan with the actual username you need

Subsequent, we have to configure Nginx in order that it restricts the precise URI with the password.

  • Let’s assume we have to shield /admin URI
  • Add the next nginx.conf or some other working Nginx configuration file
location /admin {
auth_basic "Admin Space";
auth_basic_user_file /and so forth/nginx/.htpasswd;
}
  • Restart Nginx

What if you could restrict the whole web site to be served by means of Nginx?

Easy!

Add the next in nginx.conf or the working configuration file beneath location / { guideline

auth_basic "Admin Space";
auth_basic_user_file /and so forth/nginx/.htpasswd;

SiteGround

The internet hosting platform has advanced. There are numerous platforms that supply helpful instruments, and SiteGround is one in every of them.

In the event you use SiteGround to host your web site, you may simply shield the URL by means of their admin console. Let’s assume you might be utilizing WordPress and want safety /wp-admin.

  • Login to SiteGround and go to the positioning the place you could allow primary authentication.
  • Click on Safety >> Protected URLs >> Customers
  • Enter the title and password to create the credential

Subsequent we are going to shield wp-admin with the credentials we simply created.

  • Go to the URLs tab
  • Enter wp-admin within the path and click on safe
  • Click on Handle Entry and assign the consumer you simply created

Attempt to entry the web page and SiteGround will ask you to enter the credentials.

Straightforward, is not it?

WordPress

Do you utilize WordPress and need to password shield a particular put up, web page, class, per position or the whole website?

Definitely!

Meet PPWP (WordPress Defend WordPress Plugin)

Set up the plugin and configure the way you need to shield WordPress assets. This works with web page builders like Elementor, Divi, Beaver.

Alternatively, in case you want a easy password-protected put up or web page, you may make the most of the built-in WP characteristic. You do not want a plugin for this.

  • Go to the put up or web page for which you need to allow a password.
  • Underneath the publishing part, click on Edit subsequent to Visibility: Public
  • Choose Password protected and enter the password.

  • Click on OK and also you’re achieved!

Want extra methods to safe WordPress? Take a look at this information.

cPanel

In the event you use shared internet hosting, you almost certainly have cPanel. The excellent news is that cPanel affords a utility referred to as Listing Privateness; from there you may set a password for the listing.

  • Login to cPanel
  • Seek for Listing Privateness

  • Choose the folder you need to shield. As beneath, I’ve chosen a folder named chadan, which is beneath public_html
  • Create the consumer to be allowed and put it aside

  • As soon as achieved, you’ll discover that the folder has a lock

And that is it. The folder is now password protected. As you may see above, I examined on A2 internet hosting and it really works wonderful.

Conclusion

I hope the above lets you shield sure URIs, directories with the password utilizing primary authentication. In the event you’re on the lookout for complete web site safety, think about implementing WAF.

Leave a Comment

porno izle altyazılı porno porno