HTTP Authentication is the easiest way to prevent anonymous user access to your website. If you are on Apache, you can refer to the following post.
.htaccess – Setting Password For Your Web Folder
After you have created the password file, you could add the following line in the .htaccess or in the Apache VirtualHost.
AuthName "Password Required" AuthType Basic AuthUserFile /home/ykyuen/public_html/.htpasswd require valid-user
But if you are working with Nginx, you should add the following lines on the VirtualHost instead.
server { listen 80; server_name www.ykyuen.info ykyuen.info; root /var/www/webroot; location / { # HTTP Authentication auth_basic "Restricted"; auth_basic_user_file /home/ykyuen/public_html/.htpasswd; } }
Restart the Nginx service and your website is now under protection.
Done =)
Reference: Basic HTTP Authentication With Nginx