mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -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
|
#!/bin/bash
|
||||||
# info: adding web domain nginx integration
|
# info: adding nginx support
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Variable&Function #
|
# Variable&Function #
|
||||||
|
@ -9,10 +9,9 @@
|
||||||
user="$1"
|
user="$1"
|
||||||
domain="$2"
|
domain="$2"
|
||||||
template="${3-default}"
|
template="${3-default}"
|
||||||
default_extentions="jpg jpeg gif png ico css zip tgz gz rar bz2 doc xls exe\
|
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"
|
pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg"
|
||||||
extentions="${4-$default_extentions}"
|
extentions="${4-$default_extentions}"
|
||||||
extentions=${extentions// /|} # replacing spaces with pipe char
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
@ -25,12 +24,12 @@ source $V_FUNC/domain_func.sh
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
# Checking arg number
|
||||||
check_args '2' "$#" 'user domain [template] [extentions] [conn]'
|
check_args '2' "$#" 'user domain [template] [extentions]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'domain' 'template' 'extentions'
|
format_validation 'user' 'domain' 'template' 'extentions'
|
||||||
|
|
||||||
# Checking web system is enabled
|
# Checking proxy system is enabled
|
||||||
is_system_enabled 'proxy'
|
is_system_enabled 'proxy'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
|
@ -52,47 +51,40 @@ is_web_domain_key_empty '$NGINX'
|
||||||
is_template_valid "proxy"
|
is_template_valid "proxy"
|
||||||
|
|
||||||
|
|
||||||
exit
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Get template name
|
# Defining domain parameters
|
||||||
tpl_name=$(get_web_domain_value '$TPL')
|
ip=$(get_web_domain_value '$IP')
|
||||||
tpl_file="$V_WEBTPL/$package-$tpl_name.tpl"
|
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
|
# Checking error log status
|
||||||
conf="$V_HOME/$user/conf/httpd.conf"
|
elog=$(get_web_domain_value '$ELOG')
|
||||||
|
if [ "$elog" = 'no' ]; then
|
||||||
# Defining search phrase
|
elog=' #'
|
||||||
search_phrase='ServerAlias'
|
|
||||||
|
|
||||||
# Defining new alias string
|
|
||||||
curr_alias=$(get_web_domain_value '$ALIAS')
|
|
||||||
if [ -z "$curr_alias" ]; then
|
|
||||||
new_alias="$dom_alias"
|
|
||||||
else
|
else
|
||||||
new_alias="$curr_alias,$dom_alias"
|
elog=' '
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Defining replace string
|
# Adding domain to the nginx.conf
|
||||||
str_repl=" ServerAlias ${new_alias//,/ }"
|
tpl_file="$V_WEBTPL/ngingx_vhost_$template.tpl"
|
||||||
|
conf="$V_HOME/$user/conf/nginx.conf"
|
||||||
|
httpd_add_config
|
||||||
|
|
||||||
# Adding alias
|
# Checking vesta nginx config
|
||||||
httpd_change_config
|
main_conf='/etc/nginx/conf.d/vesta_users.conf'
|
||||||
|
main_conf_check=$(grep "$conf" $main_conf )
|
||||||
# Checking ssl domain
|
if [ -z "$main_conf_check" ]; then
|
||||||
ssl=$(get_web_domain_value '$SSL')
|
echo "include $conf;" >>$main_conf
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,13 +92,14 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding new alias
|
# Adding nginx params to config
|
||||||
update_web_domain_value '$ALIAS' "$new_alias"
|
update_web_domain_value '$NGINX' "$template"
|
||||||
|
update_web_domain_value '$NGINX_EXT' "$extentions"
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
restart_schedule 'web'
|
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"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit $OK
|
||||||
|
|
|
@ -16,9 +16,8 @@ server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
location = /error/ {
|
location /error/ {
|
||||||
root %home%/%user%/domains/%domain%/document_errors/;
|
alias %home%/%user%/domains/%domain%/document_errors/;
|
||||||
try_files $uri @fallback;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
location @fallback {
|
location @fallback {
|
||||||
|
|
|
@ -16,9 +16,8 @@ server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
location = /error/ {
|
location /error/ {
|
||||||
root %home%/%user%/domains/%domain%/document_errors/;
|
alias %home%/%user%/domains/%domain%/document_errors/;
|
||||||
try_files $uri @fallback;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
location @fallback {
|
location @fallback {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue