Skip to content

Commit 495d3f7

Browse files
committed
added nginx support per domain
1 parent cbf1046 commit 495d3f7

File tree

3 files changed

+39
-48
lines changed

3 files changed

+39
-48
lines changed

bin/v_add_web_domain_nginx

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# info: adding web domain nginx integration
2+
# info: adding nginx support
33

44
#----------------------------------------------------------#
55
# Variable&Function #
@@ -9,10 +9,9 @@
99
user="$1"
1010
domain="$2"
1111
template="${3-default}"
12-
default_extentions="jpg jpeg gif png ico css zip tgz gz rar bz2 doc xls exe\
13-
pdf ppt txt tar wav bmp rtf js mp3 avi mpeg"
12+
default_extentions="jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,\
13+
pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg"
1414
extentions="${4-$default_extentions}"
15-
extentions=${extentions// /|} # replacing spaces with pipe char
1615

1716
# Importing variables
1817
source $VESTA/conf/vars.conf
@@ -25,12 +24,12 @@ source $V_FUNC/domain_func.sh
2524
#----------------------------------------------------------#
2625

2726
# Checking arg number
28-
check_args '2' "$#" 'user domain [template] [extentions] [conn]'
27+
check_args '2' "$#" 'user domain [template] [extentions]'
2928

3029
# Checking argument format
3130
format_validation 'user' 'domain' 'template' 'extentions'
3231

33-
# Checking web system is enabled
32+
# Checking proxy system is enabled
3433
is_system_enabled 'proxy'
3534

3635
# Checking user
@@ -52,61 +51,55 @@ is_web_domain_key_empty '$NGINX'
5251
is_template_valid "proxy"
5352

5453

55-
exit
5654
#----------------------------------------------------------#
5755
# Action #
5856
#----------------------------------------------------------#
5957

60-
# Get template name
61-
tpl_name=$(get_web_domain_value '$TPL')
62-
tpl_file="$V_WEBTPL/$package-$tpl_name.tpl"
63-
64-
# Defining config
65-
conf="$V_HOME/$user/conf/httpd.conf"
66-
67-
# Defining search phrase
68-
search_phrase='ServerAlias'
69-
70-
# Defining new alias string
71-
curr_alias=$(get_web_domain_value '$ALIAS')
72-
if [ -z "$curr_alias" ]; then
73-
new_alias="$dom_alias"
58+
# Defining domain parameters
59+
ip=$(get_web_domain_value '$IP')
60+
web_port=$(get_config_value '$WEB_PORT')
61+
proxy_port=$(get_config_value '$PROXY_PORT')
62+
domain=$(get_web_domain_value '$DOMAIN')
63+
domain_idn=$(idn -t --quiet -a "$domain")
64+
group="$user"
65+
docroot="$V_HOME/$user/domains/$domain/public_html"
66+
email="$user@$domain"
67+
aliases=$(get_web_domain_value '$ALIAS')
68+
aliases_idn=$(idn -t --quiet -a "$aliases")
69+
70+
# Checking error log status
71+
elog=$(get_web_domain_value '$ELOG')
72+
if [ "$elog" = 'no' ]; then
73+
elog=' #'
7474
else
75-
new_alias="$curr_alias,$dom_alias"
75+
elog=' '
7676
fi
7777

78-
# Defining replace string
79-
str_repl=" ServerAlias ${new_alias//,/ }"
80-
81-
# Adding alias
82-
httpd_change_config
83-
84-
# Checking ssl domain
85-
ssl=$(get_web_domain_value '$SSL')
86-
if [ "$ssl" = 'yes' ]; then
87-
88-
# Defining ssl template
89-
tpl_file="$V_WEBTPL/$package-$tpl_name.ssl.tpl"
90-
91-
# Defining ssl config
92-
conf="$V_HOME/$user/conf/shttpd.conf"
78+
# Adding domain to the nginx.conf
79+
tpl_file="$V_WEBTPL/ngingx_vhost_$template.tpl"
80+
conf="$V_HOME/$user/conf/nginx.conf"
81+
httpd_add_config
9382

94-
# Adding alias
95-
httpd_change_config
83+
# Checking vesta nginx config
84+
main_conf='/etc/nginx/conf.d/vesta_users.conf'
85+
main_conf_check=$(grep "$conf" $main_conf )
86+
if [ -z "$main_conf_check" ]; then
87+
echo "include $conf;" >>$main_conf
9688
fi
9789

9890

9991
#----------------------------------------------------------#
10092
# Vesta #
10193
#----------------------------------------------------------#
10294

103-
# Adding new alias
104-
update_web_domain_value '$ALIAS' "$new_alias"
95+
# Adding nginx params to config
96+
update_web_domain_value '$NGINX' "$template"
97+
update_web_domain_value '$NGINX_EXT' "$extentions"
10598

10699
# Adding task to the vesta pipe
107100
restart_schedule 'web'
108101

109-
log_history "$V_EVENT" "v_del_web_domain_alias $user $domain $dom_alias"
102+
log_history "$V_EVENT" "v_del_web_domain_nginx $user $domain"
110103
log_event 'system' "$V_EVENT"
111104

112105
exit $OK

data/templates/ngingx_vhost_default.stpl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ server {
1616
}
1717
}
1818

19-
location = /error/ {
20-
root %home%/%user%/domains/%domain%/document_errors/;
21-
try_files $uri @fallback;
19+
location /error/ {
20+
alias %home%/%user%/domains/%domain%/document_errors/;
2221
}
2322

2423
location @fallback {

data/templates/ngingx_vhost_default.tpl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ server {
1616
}
1717
}
1818

19-
location = /error/ {
20-
root %home%/%user%/domains/%domain%/document_errors/;
21-
try_files $uri @fallback;
19+
location /error/ {
20+
alias %home%/%user%/domains/%domain%/document_errors/;
2221
}
2322

2423
location @fallback {

0 commit comments

Comments
 (0)