Skip to content

Commit 9f1d16d

Browse files
committed
added ssl support
1 parent 1ad0295 commit 9f1d16d

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

bin/v_add_web_domain_nginx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ is_template_valid "proxy"
5959
ip=$(get_web_domain_value '$IP')
6060
web_port=$(get_config_value '$WEB_PORT')
6161
proxy_port=$(get_config_value '$PROXY_PORT')
62-
domain=$(get_web_domain_value '$DOMAIN')
6362
domain_idn=$(idn -t --quiet -a "$domain")
6463
group="$user"
6564
docroot="$V_HOME/$user/domains/$domain/public_html"
@@ -87,6 +86,34 @@ if [ -z "$main_conf_check" ]; then
8786
echo "include $conf;" >>$main_conf
8887
fi
8988

89+
# Checking ssl
90+
cert=$(get_web_domain_value '$SSL_CERT')
91+
if [ ! -z "$cert" ]; then
92+
# Defining certificate params
93+
ssl_cert="$V_HOME/$user/conf/$cert.crt"
94+
ssl_key="$V_HOME/$user/conf/$cert.key"
95+
tpl_option=$(get_web_domain_value '$SSL_HOME')
96+
case $tpl_option in
97+
single) docroot="$V_HOME/$user/domains/$domain/public_shtml" ;;
98+
same) docroot="$V_HOME/$user/domains/$domain/public_html" ;;
99+
*) check_args '3' "$#" 'user domain certificate [sslhome]'
100+
esac
101+
web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
102+
proxy_ssl_port=$(get_config_value '$PROXY_SSL_PORT')
103+
104+
# Adding domain to the snginx.conf
105+
conf="$V_HOME/$user/conf/snginx.conf"
106+
tpl_file="$V_WEBTPL/ngingx_vhost_$template.stpl"
107+
httpd_add_config
108+
109+
# Checking vesta nginx config
110+
main_conf='/etc/nginx/conf.d/vesta_users.conf'
111+
main_conf_check=$(grep "$conf" $main_conf )
112+
if [ -z "$main_conf_check" ]; then
113+
echo "include $conf;" >>$main_conf
114+
fi
115+
fi
116+
90117

91118
#----------------------------------------------------------#
92119
# Vesta #

bin/v_rebuild_web_domains

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ field='$DOMAIN'
5151
# Parsing unsuspeneded domains
5252
domains=$(dom_clear_search)
5353

54-
# Starting update disk loop
54+
# Starting loop
5555
for domain in $domains; do
5656

5757
# Defining domain parameters
@@ -85,10 +85,9 @@ for domain in $domains; do
8585
fi
8686

8787
# Checking ssl
88-
ssl=$(get_web_domain_value '$SSL')
89-
if [ "$ssl" = 'yes' ]; then
90-
# Parsing certificate params
91-
cert=$(get_web_domain_value '$SSL_CERT')
88+
cert=$(get_web_domain_value '$SSL_CERT')
89+
if [ ! -z "$cert" ]; then
90+
# Defining certificate params
9291
ssl_cert="$V_HOME/$user/conf/$cert.crt"
9392
ssl_key="$V_HOME/$user/conf/$cert.key"
9493
tpl_option=$(get_web_domain_value '$SSL_HOME')
@@ -99,7 +98,7 @@ for domain in $domains; do
9998
esac
10099
web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
101100

102-
# Adding domain to the httpd.conf
101+
# Adding domain to the shttpd.conf
103102
conf="$V_HOME/$user/conf/tmp_shttpd.conf"
104103
tpl_file="$V_WEBTPL/apache_$template.stpl"
105104
httpd_add_config

data/templates/ngingx_vhost_default.stpl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ server {
22
listen %ip%:%proxy_ssl_port%;
33
server_name %domain_idn% %alias_idn%;
44
server_name_in_redirect off;
5+
ssl on;
6+
ssl_certificate %ssl_cert%;
7+
ssl_certificate_key %ssl_key%;
58
%elog%error_log /var/log/httpd/domains/%domain%.error.log error;
69

710
location / {
8-
proxy_pass http://%ip%:%web_ssl_port%;
11+
proxy_pass https://%ip%:%web_ssl_port%;
912

1013
location ~* ^.+\.(%extentions%)$ {
1114
root %docroot%;
@@ -21,7 +24,7 @@ server {
2124
}
2225

2326
location @fallback {
24-
proxy_pass http://%ip%:%web_ssl_port%;
27+
proxy_pass https://%ip%:%web_ssl_port%;
2528
}
2629

2730
location ~ /\.ht {deny all;}

0 commit comments

Comments
 (0)