|
|
@ -40,6 +40,7 @@ export -f apache_publish_dir |
|
|
|
|
|
|
|
|
|
|
|
apache_vhost_create () { |
|
|
|
local custom_rules |
|
|
|
export APACHE_CONFIG_LOCATION="$SERVICE_CONFIGSTORE/etc/apache2/sites-enabled" vhost_statement |
|
|
|
|
|
|
|
SERVER_ALIAS=$(relation-get server-aliases 2>/dev/null) || true |
|
|
@ -50,6 +51,25 @@ apache_vhost_create () { |
|
|
|
if is_protocol_enabled https; then |
|
|
|
read-0 SSL_PLUGIN_FUN SSL_CFG_VALUE SSL_CFG_OPTIONS < <(ssl_get_plugin_fun) || return 1 |
|
|
|
"$SSL_PLUGIN_FUN"_vars "$SSL_CFG_OPTIONS" "$SSL_CFG_VALUE" || return 1 |
|
|
|
redirect=$(relation-get 'redirect-to-ssl' 2>/dev/null) || true |
|
|
|
if is_protocol_enabled http; then |
|
|
|
redirect=${redirect:-true} |
|
|
|
else |
|
|
|
redirect=false |
|
|
|
fi |
|
|
|
if [ "$redirect" == "true" ]; then |
|
|
|
custom_rules=$(_get_custom_rules) || return 1 |
|
|
|
if [[ "$custom_rules" != *"## Auto-redirection from http to https"* ]]; then |
|
|
|
relation-set apache-custom-rules "- | |
|
|
|
## Auto-redirection from http to https |
|
|
|
RewriteEngine On |
|
|
|
RewriteCond %{HTTPS} off |
|
|
|
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,QSA] |
|
|
|
$(if [ "$custom_rules" ]; then |
|
|
|
echo "- |"$'\n'"$(echo "$custom_rules" | prefix " ")" |
|
|
|
fi)" |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
vhost_statement=$(apache_vhost_statement "$PROTOCOLS") || return 1 |
|
|
|
echo "$vhost_statement"| file_put "$APACHE_CONFIG_LOCATION/$prefix$DOMAIN.conf" || return 1 |
|
|
@ -100,7 +120,7 @@ __vhost_cfg_normalize_protocol() { |
|
|
|
case "$protocol" in |
|
|
|
auto) |
|
|
|
if __vhost_cfg_ssl="$(_get_ssl_option_value)"; then |
|
|
|
protocol="https" |
|
|
|
protocol="http,https" |
|
|
|
export __vhost_cfg_ssl |
|
|
|
else |
|
|
|
protocol="http" |
|
|
|