Serghey Rodin 14 rokov pred
rodič
commit
9f1d16d87a

+ 28 - 1
bin/v_add_web_domain_nginx

@@ -59,7 +59,6 @@ is_template_valid "proxy"
 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"
@@ -87,6 +86,34 @@ if [ -z "$main_conf_check" ]; then
     echo "include $conf;" >>$main_conf
 fi
 
+# Checking ssl
+cert=$(get_web_domain_value '$SSL_CERT')
+if [ ! -z "$cert" ]; then
+    # Defining certificate params
+    ssl_cert="$V_HOME/$user/conf/$cert.crt"
+    ssl_key="$V_HOME/$user/conf/$cert.key"
+    tpl_option=$(get_web_domain_value '$SSL_HOME')
+    case $tpl_option in
+        single) docroot="$V_HOME/$user/domains/$domain/public_shtml" ;;
+        same) docroot="$V_HOME/$user/domains/$domain/public_html" ;;
+        *) check_args '3' "$#" 'user domain certificate [sslhome]'
+    esac
+    web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
+    proxy_ssl_port=$(get_config_value '$PROXY_SSL_PORT')
+
+    # Adding domain to the snginx.conf
+    conf="$V_HOME/$user/conf/snginx.conf"
+    tpl_file="$V_WEBTPL/ngingx_vhost_$template.stpl"
+    httpd_add_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
+fi
+
 
 #----------------------------------------------------------#
 #                       Vesta                              #

+ 5 - 6
bin/v_rebuild_web_domains

@@ -51,7 +51,7 @@ field='$DOMAIN'
 # Parsing unsuspeneded domains
 domains=$(dom_clear_search)
 
-# Starting update disk loop
+# Starting loop
 for domain in $domains; do
 
     # Defining domain parameters
@@ -85,10 +85,9 @@ for domain in $domains; do
     fi
 
     # Checking ssl
-    ssl=$(get_web_domain_value '$SSL')
-    if [ "$ssl" = 'yes' ]; then
-        # Parsing certificate params
-        cert=$(get_web_domain_value '$SSL_CERT')
+    cert=$(get_web_domain_value '$SSL_CERT')
+    if [ ! -z "$cert" ]; then
+        # Defining certificate params
         ssl_cert="$V_HOME/$user/conf/$cert.crt"
         ssl_key="$V_HOME/$user/conf/$cert.key"
         tpl_option=$(get_web_domain_value '$SSL_HOME')
@@ -99,7 +98,7 @@ for domain in $domains; do
         esac
         web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
 
-        # Adding domain to the httpd.conf
+        # Adding domain to the shttpd.conf
         conf="$V_HOME/$user/conf/tmp_shttpd.conf"
         tpl_file="$V_WEBTPL/apache_$template.stpl"
         httpd_add_config

+ 5 - 2
data/templates/ngingx_vhost_default.stpl

@@ -2,10 +2,13 @@ server {
     listen      %ip%:%proxy_ssl_port%;
     server_name %domain_idn% %alias_idn%;
     server_name_in_redirect off;
+    ssl         on;
+    ssl_certificate      %ssl_cert%;
+    ssl_certificate_key  %ssl_key%;
    %elog%error_log  /var/log/httpd/domains/%domain%.error.log error;
 
     location / {
-        proxy_pass     http://%ip%:%web_ssl_port%;
+        proxy_pass     https://%ip%:%web_ssl_port%;
 
         location ~* ^.+\.(%extentions%)$ {
             root           %docroot%;
@@ -21,7 +24,7 @@ server {
     }
 
     location @fallback {
-        proxy_pass      http://%ip%:%web_ssl_port%;
+        proxy_pass      https://%ip%:%web_ssl_port%;
     }
 
     location ~ /\.ht   {deny all;}