@@ -30,10 +30,7 @@ source $HESTIA/func/domain.sh
3030source_conf " $HESTIA /conf/hestia.conf"
3131
3232# Defining htpasswd file
33- htaccess=" $HOMEDIR /$user /conf/web/$domain /htaccess"
3433htpasswd=" $HOMEDIR /$user /conf/web/$domain /htpasswd"
35- shtaccess=" $htaccess "
36- shtpasswd=" $htpasswd "
3734docroot=" $HOMEDIR /$user /web/$domain /public_html"
3835
3936# Perform verification if read-only mode is enabled
6360# Action #
6461# ----------------------------------------------------------#
6562
63+
6664# Adding htaccess password protection
67- if [ ! -e " $htaccess " ]; then
68- if [ " $WEB_SYSTEM " != ' nginx' ]; then
69- echo " <Directory $docroot >" > $htaccess
70- echo " AuthUserFile $htpasswd " >> $htaccess
71- echo " AuthName \" $domain access\" " >> $htaccess
72- echo " AuthType Basic" >> $htaccess
73- echo " Require valid-user" >> $htaccess
74- echo " </Directory>" >> $htaccess
65+ if [ " $WEB_SYSTEM " = " nginx" ] || [ " $PROXY_SYSTEM " = " nginx" ]; then
66+ htaccess=" $HOMEDIR /$user /conf/web/$domain /nginx.conf_htaccess"
67+ shtaccess=" $HOMEDIR /$user /conf/web/$domain /nginx.ssl.conf_htaccess"
68+ if [ ! -f " $htaccess " ]; then
69+ echo " auth_basic \" $domain password access\" ;" > $htaccess
70+ echo " auth_basic_user_file $htpasswd ;" >> $htaccess
71+ ln -s $htaccess $shtaccess
72+ restart_required=' yes'
73+ fi
7574 else
76- echo " auth_basic \" $domain password access\" ;" > $htaccess
77- echo " auth_basic_user_file $htpasswd ;" >> $htaccess
75+ htaccess=" $HOMEDIR /$user /conf/web/$domain /apache2.conf_htaccess"
76+ shtaccess=" $HOMEDIR /$user /conf/web/$domain /apache2.ssl.conf_htaccess"
77+ if [ ! -f " $htaccess " ]; then
78+ echo " <Directory $docroot >" > $htaccess
79+ echo " AuthUserFile $htpasswd " >> $htaccess
80+ echo " AuthName \" $domain access\" " >> $htaccess
81+ echo " AuthType Basic" >> $htaccess
82+ echo " Require valid-user" >> $htaccess
83+ echo " </Directory>" >> $htaccess
84+ ln -s $htaccess $shtaccess
85+ restart_required=' yes'
86+ fi
7887 fi
79- restart_required=' yes'
80- fi
88+
8189
8290# Adding httpasswd user
8391auth_hash=$( $BIN /v-generate-password-hash htpasswd htpasswd $password )
8492touch $htpasswd
85- chmod 640 $htpasswd $htaccess
93+ chmod 644 $htpasswd $htaccess
8694chgrp $user $htpasswd $htaccess
8795sed -i " /^$auth_user :/d" $htpasswd
8896echo " $auth_user :$auth_hash " >> $htpasswd
8997
90- # Symbolic link for secure web templates
91- if [ ! -L " $shtpasswd " ]; then
92- ln -s $htpasswd $shtpasswd
93- fi
94- if [ ! -L " $shtaccess " ]; then
95- ln -s $htaccess $shtaccess
96- fi
97-
9898# Restarting web server
9999if [ " $restart " != ' no' ] && [ " $restart_required " = ' yes' ]; then
100100 $BIN /v-restart-web
101+ if [ -n " $PROXY_SYSTEM " ]; then
102+ $BIN /v-restart-proxy
103+ fi
101104fi
102105
103106# ----------------------------------------------------------#
0 commit comments