diff --git a/plugins/nginx-vhosts/functions b/plugins/nginx-vhosts/functions index 9edfd99da..809694085 100755 --- a/plugins/nginx-vhosts/functions +++ b/plugins/nginx-vhosts/functions @@ -348,3 +348,22 @@ nginx_build_config() { fi fi } + +# @TODO: Remove this after a few versions +migrate_nginx_to_proxy() { + declare desc="migrates DOKKU_NGINX_* to DOKKI_PROXY_*" + for app in $(dokku_apps); do + local nginx_port="$(config_get "$app" DOKKU_NGINX_PORT || true)" + local nginx_ssl_port="$(config_get "$app" DOKKU_NGINX_SSL_PORT || true)" + if [[ -n "$nginx_port" ]]; then + dokku_log_info1 "Migrating DOKKU_NGINX_PORT to DOKKU_PROXY_PORT for $app" + config_set --no-restart "$app" DOKKU_PROXY_PORT="$nginx_port" + config_unset --no-restart "$app" DOKKU_NGINX_PORT + fi + if [[ -n "$nginx_ssl_port" ]]; then + dokku_log_info1 "Migrating DOKKU_NGINX_SSL_PORT to DOKKU_PROXY_SSL_PORT for $app" + config_set --no-restart "$app" DOKKU_PROXY_SSL_PORT="$nginx_ssl_port" + config_unset --no-restart "$app" DOKKU_NGINX_SSL_PORT + fi + done +} diff --git a/plugins/nginx-vhosts/install b/plugins/nginx-vhosts/install index 0d7513208..58a92da26 100755 --- a/plugins/nginx-vhosts/install +++ b/plugins/nginx-vhosts/install @@ -1,5 +1,7 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/config/functions" case "$DOKKU_DISTRO" in debian) @@ -73,6 +75,8 @@ cp "${PLUGIN_CORE_AVAILABLE_PATH}/nginx-vhosts/templates/500-error.html" "${DOKK # patch broken nginx 1.8.0 logrotate [[ -f /etc/logrotate.d/nginx ]] && sed -i -e 's/invoke-rc.d/service/g' /etc/logrotate.d/nginx +migrate_nginx_to_proxy + case "$DOKKU_DISTRO" in debian) NGINX_INIT="/usr/sbin/invoke-rc.d" diff --git a/plugins/nginx-vhosts/subcommands/migrate b/plugins/nginx-vhosts/subcommands/migrate new file mode 100644 index 000000000..36cc089b4 --- /dev/null +++ b/plugins/nginx-vhosts/subcommands/migrate @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/config/functions" +source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" + +nginx_migrate_cmd() { + declare desc="converts DOKKU_NGINX_* to DOKKI_PROXY_*" + local cmd="nginx:migrate" + migrate_nginx_to_proxy +} + +nginx_migrate_cmd diff --git a/plugins/nginx-vhosts/templates/nginx.conf.sigil b/plugins/nginx-vhosts/templates/nginx.conf.sigil index c05ed954d..3f2036fdf 100644 --- a/plugins/nginx-vhosts/templates/nginx.conf.sigil +++ b/plugins/nginx-vhosts/templates/nginx.conf.sigil @@ -12,7 +12,7 @@ server { access_log /var/log/nginx/{{ $.APP }}-access.log; error_log /var/log/nginx/{{ $.APP }}-error.log; {{ if (and (eq $listen_port "80") ($.SSL_INUSE)) }} - return 301 https://$host:{{ $.NGINX_SSL_PORT }}$request_uri; + return 301 https://$host:{{ $.PROXY_SSL_PORT }}$request_uri; {{ else }} location / { @@ -69,7 +69,7 @@ server { ssl_prefer_server_ciphers on; keepalive_timeout 70; - {{ if and (eq $.SPDY_SUPPORTED "true") (ne $.HTTP2_SUPPORTED "true") }}add_header Alternate-Protocol {{ $.NGINX_SSL_PORT }}:npn-spdy/2;{{ end }} + {{ if and (eq $.SPDY_SUPPORTED "true") (ne $.HTTP2_SUPPORTED "true") }}add_header Alternate-Protocol {{ $.PROXY_SSL_PORT }}:npn-spdy/2;{{ end }} location / {