mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 18:49:21 -07:00
added nginx support per domain
This commit is contained in:
parent
cbf1046322
commit
495d3f7a18
3 changed files with 38 additions and 47 deletions
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# info: adding web domain nginx integration
|
||||
# info: adding nginx support
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
|
@ -9,10 +9,9 @@
|
|||
user="$1"
|
||||
domain="$2"
|
||||
template="${3-default}"
|
||||
default_extentions="jpg jpeg gif png ico css zip tgz gz rar bz2 doc xls exe\
|
||||
pdf ppt txt tar wav bmp rtf js mp3 avi mpeg"
|
||||
default_extentions="jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,\
|
||||
pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg"
|
||||
extentions="${4-$default_extentions}"
|
||||
extentions=${extentions// /|} # replacing spaces with pipe char
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
|
@ -25,12 +24,12 @@ source $V_FUNC/domain_func.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking arg number
|
||||
check_args '2' "$#" 'user domain [template] [extentions] [conn]'
|
||||
check_args '2' "$#" 'user domain [template] [extentions]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'domain' 'template' 'extentions'
|
||||
|
||||
# Checking web system is enabled
|
||||
# Checking proxy system is enabled
|
||||
is_system_enabled 'proxy'
|
||||
|
||||
# Checking user
|
||||
|
@ -52,47 +51,40 @@ is_web_domain_key_empty '$NGINX'
|
|||
is_template_valid "proxy"
|
||||
|
||||
|
||||
exit
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Get template name
|
||||
tpl_name=$(get_web_domain_value '$TPL')
|
||||
tpl_file="$V_WEBTPL/$package-$tpl_name.tpl"
|
||||
# Defining domain parameters
|
||||
ip=$(get_web_domain_value '$IP')
|
||||
web_port=$(get_config_value '$WEB_PORT')
|
||||
proxy_port=$(get_config_value '$PROXY_PORT')
|
||||
domain=$(get_web_domain_value '$DOMAIN')
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
group="$user"
|
||||
docroot="$V_HOME/$user/domains/$domain/public_html"
|
||||
email="$user@$domain"
|
||||
aliases=$(get_web_domain_value '$ALIAS')
|
||||
aliases_idn=$(idn -t --quiet -a "$aliases")
|
||||
|
||||
# Defining config
|
||||
conf="$V_HOME/$user/conf/httpd.conf"
|
||||
|
||||
# Defining search phrase
|
||||
search_phrase='ServerAlias'
|
||||
|
||||
# Defining new alias string
|
||||
curr_alias=$(get_web_domain_value '$ALIAS')
|
||||
if [ -z "$curr_alias" ]; then
|
||||
new_alias="$dom_alias"
|
||||
# Checking error log status
|
||||
elog=$(get_web_domain_value '$ELOG')
|
||||
if [ "$elog" = 'no' ]; then
|
||||
elog=' #'
|
||||
else
|
||||
new_alias="$curr_alias,$dom_alias"
|
||||
elog=' '
|
||||
fi
|
||||
|
||||
# Defining replace string
|
||||
str_repl=" ServerAlias ${new_alias//,/ }"
|
||||
# Adding domain to the nginx.conf
|
||||
tpl_file="$V_WEBTPL/ngingx_vhost_$template.tpl"
|
||||
conf="$V_HOME/$user/conf/nginx.conf"
|
||||
httpd_add_config
|
||||
|
||||
# Adding alias
|
||||
httpd_change_config
|
||||
|
||||
# Checking ssl domain
|
||||
ssl=$(get_web_domain_value '$SSL')
|
||||
if [ "$ssl" = 'yes' ]; then
|
||||
|
||||
# Defining ssl template
|
||||
tpl_file="$V_WEBTPL/$package-$tpl_name.ssl.tpl"
|
||||
|
||||
# Defining ssl config
|
||||
conf="$V_HOME/$user/conf/shttpd.conf"
|
||||
|
||||
# Adding alias
|
||||
httpd_change_config
|
||||
# Checking vesta nginx config
|
||||
main_conf='/etc/nginx/conf.d/vesta_users.conf'
|
||||
main_conf_check=$(grep "$conf" $main_conf )
|
||||
if [ -z "$main_conf_check" ]; then
|
||||
echo "include $conf;" >>$main_conf
|
||||
fi
|
||||
|
||||
|
||||
|
@ -100,13 +92,14 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Adding new alias
|
||||
update_web_domain_value '$ALIAS' "$new_alias"
|
||||
# Adding nginx params to config
|
||||
update_web_domain_value '$NGINX' "$template"
|
||||
update_web_domain_value '$NGINX_EXT' "$extentions"
|
||||
|
||||
# Adding task to the vesta pipe
|
||||
restart_schedule 'web'
|
||||
|
||||
log_history "$V_EVENT" "v_del_web_domain_alias $user $domain $dom_alias"
|
||||
log_history "$V_EVENT" "v_del_web_domain_nginx $user $domain"
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue