|
|
@ -40,7 +40,7 @@ export -f apache_publish_dir |
|
|
|
|
|
|
|
|
|
|
|
apache_vhost_create () { |
|
|
|
export APACHE_CONFIG_LOCATION="$SERVICE_CONFIGSTORE/etc/apache2/sites-enabled" |
|
|
|
export APACHE_CONFIG_LOCATION="$SERVICE_CONFIGSTORE/etc/apache2/sites-enabled" vhost_statement |
|
|
|
|
|
|
|
SERVER_ALIAS=$(relation-get server-aliases 2>/dev/null) || true |
|
|
|
PROTOCOLS=$(__vhost_cfg_normalize_protocol) || return 1 |
|
|
@ -51,8 +51,8 @@ apache_vhost_create () { |
|
|
|
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 |
|
|
|
fi |
|
|
|
apache_vhost_statement "$PROTOCOLS" | |
|
|
|
file_put "$APACHE_CONFIG_LOCATION/$prefix$DOMAIN.conf" || return 1 |
|
|
|
vhost_statement=$(apache_vhost_statement "$PROTOCOLS") || return 1 |
|
|
|
echo "$vhost_statement"| file_put "$APACHE_CONFIG_LOCATION/$prefix$DOMAIN.conf" || return 1 |
|
|
|
|
|
|
|
__vhost_cfg_creds_enabled=$(relation-get creds 2>/dev/null) || true |
|
|
|
if [ "$__vhost_cfg_creds_enabled" ]; then |
|
|
@ -285,14 +285,15 @@ apache_vhost_statement() { |
|
|
|
export PROTOCOLS="$1" |
|
|
|
|
|
|
|
if is_protocol_enabled http; then |
|
|
|
__vhost_full_vhost_statement http |
|
|
|
__vhost_full_vhost_statement http || return 1 |
|
|
|
fi |
|
|
|
if is_protocol_enabled https; then |
|
|
|
"$SSL_PLUGIN_FUN"_vars "$(_get_ssl_option_value 2>/dev/null)" |
|
|
|
"$SSL_PLUGIN_FUN"_vars "$(_get_ssl_option_value 2>/dev/null)" || return 1 |
|
|
|
vhost_statement=$(__vhost_full_vhost_statement https) || return 1 |
|
|
|
cat <<EOF |
|
|
|
|
|
|
|
<IfModule mod_ssl.c> |
|
|
|
$(__vhost_full_vhost_statement https | prefix " ") |
|
|
|
$(echo "$vhost_statement" | prefix " ") |
|
|
|
</IfModule> |
|
|
|
EOF |
|
|
|
fi |
|
|
@ -476,9 +477,9 @@ EOF |
|
|
|
|
|
|
|
__vhost_content_statement() { |
|
|
|
if [ "$proxy" ]; then |
|
|
|
__vhost_proxy_statement "$@" |
|
|
|
__vhost_proxy_statement "$@" || return 1 |
|
|
|
else |
|
|
|
__vhost_publish_dir_statement "$@" |
|
|
|
__vhost_publish_dir_statement "$@" || return 1 |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
@ -500,6 +501,7 @@ __vhost_proxy_statement() { |
|
|
|
|
|
|
|
cat <<EOF |
|
|
|
|
|
|
|
|
|
|
|
## |
|
|
|
## Proxy declaration towards $TARGET |
|
|
|
## |
|
|
@ -528,7 +530,11 @@ EOF |
|
|
|
} |
|
|
|
|
|
|
|
__vhost_full_vhost_statement() { |
|
|
|
local protocol="$1" |
|
|
|
local protocol="$1" head_statement custom_rules content_statement |
|
|
|
|
|
|
|
head_statement=$(__vhost_head_statement "$protocol") || return 1 |
|
|
|
custom_rules=$(__vhost_custom_rules) || return 1 |
|
|
|
content_statement=$(__vhost_content_statement "$protocol") || return 1 |
|
|
|
|
|
|
|
case "$protocol" in |
|
|
|
https) |
|
|
@ -542,9 +548,9 @@ __vhost_full_vhost_statement() { |
|
|
|
cat <<EOF |
|
|
|
<VirtualHost *:$PORT> |
|
|
|
|
|
|
|
$(__vhost_head_statement "$protocol" | prefix " " && echo) |
|
|
|
$(__vhost_custom_rules | prefix " " && echo) |
|
|
|
$(__vhost_content_statement "$protocol" | prefix " ") |
|
|
|
$(echo "$head_statement" | prefix " ") |
|
|
|
$(echo "$custom_rules" | prefix " ") |
|
|
|
$(echo "$content_statement" | prefix " ") |
|
|
|
|
|
|
|
## Forbid any cache, this is only usefull on dev server. |
|
|
|
#Header set Cache-Control "no-cache" |
|
|
|