Page 1 of 1

htaccess protect Vesta

Posted: Sun Aug 14, 2016 7:22 pm
by petr.dudi
Please how can protect Vesta with htaccess.

I want protect vesta with htaccess Authentication.

Re: htaccess protect Vesta

Posted: Mon Aug 15, 2016 7:20 am
by skurudo
Nope, Vesta use nginx and nginx not support htaccess.

If you want add access from IP you can try this code in /usr/local/vesta/nginx/conf/nginx.conf

Code: Select all

location / {
allow 192.168.1.100;
deny all;
expires max;
index index.php;
}
If you wih add additional authorization, you can do it with nginx - http://nginx.org/en/docs/http/ngx_http_ ... odule.html

Example (not tested):
Create a .htpasswd file under your website directory being served by nginx. The following command would create the file and also add the user and an encrypted password to it.

Code: Select all

  sudo htpasswd -c /etc/nginx/.htpasswd exampleuser
The tool will prompt you for a password.

Code: Select all

New password:
Re-type new password:
Adding password for user exampleuser
The structure of the htpasswd file would be like this:

Code: Select all

login:password
Then add the two lines into the following path:
/usr/local/vesta/nginx/conf/nginx.conf

Code: Select all

location / {
 auth_basic "Restricted";
 auth_basic_user_file /etc/nginx/.htpasswd;
expires max;
index index.php;
}
and restart Vesta services

Code: Select all

service vesta restart