Merge pull request #1700 from progrium/1697_mh-copy-nginx-ssl-template-from-container

copy nginx.ssl.template from app container
This commit is contained in:
Michael Hobbs committed 2015-11-18 19:26:49 -05:00
commit 3e466917fd
4 files changed
+11 -8

No files matched your search

+1 -2
View File
@@ -16,8 +16,7 @@ nginx:error-logs <app> [-t] Show the nginx error logs for a
Dokku currently templates out an nginx configuration that is included in the `nginx-vhosts` plugin. If you'd like to provide a custom template for your application, there are a few options: Dokku currently templates out an nginx configuration that is included in the `nginx-vhosts` plugin. If you'd like to provide a custom template for your application, there are a few options:
- Copy the existing template - ssl or non-ssl - into your application repository's root directory as the file `nginx.conf.template`. - Copy the existing pertinent (ssl or non-ssl) template found (by default) in `/var/lib/dokku/plugins/available/nginx-vhosts/templates`, place it either in `/home/dokku/APP` or check it into your app repo, and name it one of the following:
- Create a template file in `/home/dokku/APP` named one of the following:
- `nginx.conf.template` (since 0.3.10) - `nginx.conf.template` (since 0.3.10)
- `nginx.conf.ssl_terminated.template` (since 0.4.0) - `nginx.conf.ssl_terminated.template` (since 0.4.0)
- `nginx.ssl.conf.template` (since 0.4.2) - `nginx.ssl.conf.template` (since 0.4.2)
+5 -3
View File
@@ -157,7 +157,9 @@ nginx_build_config() {
fi fi
DOKKU_APP_CIDS=($(get_app_container_ids $APP)) DOKKU_APP_CIDS=($(get_app_container_ids $APP))
docker cp "${DOKKU_APP_CIDS[0]}:/app/nginx.conf.template" "$DOKKU_ROOT/$APP/" 2> /dev/null || true for file in nginx.conf.template nginx.ssl.conf.template; do
docker cp "${DOKKU_APP_CIDS[0]}:/app/${file}" "$DOKKU_ROOT/$APP/" 2> /dev/null || true
done
[[ -f "$APP_NGINX_TEMPLATE" ]] && NGINX_TEMPLATE="$APP_NGINX_TEMPLATE" && NGINX_CUSTOM_TEMPLATE="true" && dokku_log_info1 'Overriding default nginx.conf with detected nginx.conf.template' [[ -f "$APP_NGINX_TEMPLATE" ]] && NGINX_TEMPLATE="$APP_NGINX_TEMPLATE" && NGINX_CUSTOM_TEMPLATE="true" && dokku_log_info1 'Overriding default nginx.conf with detected nginx.conf.template'
@@ -235,7 +237,7 @@ EOF
while read -r line; do while read -r line; do
[[ -z "$line" ]] && continue [[ -z "$line" ]] && continue
dokku_log_info1 "Configuring SSL for $line..." dokku_log_info1 "Configuring SSL for $line...(using $NGINX_SSL_TEMPLATE)"
SSL_SERVER_NAME=$line SSL_SERVER_NAME=$line
NOSSL_SERVER_NAME=$line NOSSL_SERVER_NAME=$line
eval "cat <<< \"$(< $NGINX_SSL_TEMPLATE)\" >> $NGINX_CONF" eval "cat <<< \"$(< $NGINX_SSL_TEMPLATE)\" >> $NGINX_CONF"
@@ -250,7 +252,7 @@ EOF
if [[ -n "$NONSSL_VHOSTS" ]]; then if [[ -n "$NONSSL_VHOSTS" ]]; then
NOSSL_SERVER_NAME=$(echo $NONSSL_VHOSTS | tr '\n' ' ') NOSSL_SERVER_NAME=$(echo $NONSSL_VHOSTS | tr '\n' ' ')
xargs -i echo "-----> Configuring {}..." <<< "$NONSSL_VHOSTS" xargs -i echo "-----> Configuring {}...(using $NGINX_TEMPLATE)" <<< "$NONSSL_VHOSTS"
eval "cat <<< \"$(< $NGINX_TEMPLATE)\" >> $NGINX_CONF" eval "cat <<< \"$(< $NGINX_TEMPLATE)\" >> $NGINX_CONF"
fi fi
if [[ "$(is_app_vhost_enabled $APP)" == "false" ]] || ([[ -z "$NONSSL_VHOSTS" ]] && [[ -z "$SSL_VHOSTS" ]]); then if [[ "$(is_app_vhost_enabled $APP)" == "false" ]] || ([[ -z "$NONSSL_VHOSTS" ]] && [[ -z "$SSL_VHOSTS" ]]); then
+2
View File
@@ -98,6 +98,7 @@ assert_error_log() {
deploy_app deploy_app
assert_ssl_domain "wildcard1.dokku.me" assert_ssl_domain "wildcard1.dokku.me"
assert_ssl_domain "wildcard2.dokku.me" assert_ssl_domain "wildcard2.dokku.me"
assert_http_success "customssltemplate.dokku.me"
} }
@test "(nginx-vhosts) nginx:build-config (wildcard SSL & unrelated domain)" { @test "(nginx-vhosts) nginx:build-config (wildcard SSL & unrelated domain)" {
@@ -125,6 +126,7 @@ assert_error_log() {
custom_nginx_template custom_nginx_template
deploy_app deploy_app
assert_nonssl_domain "www.test.app.dokku.me" assert_nonssl_domain "www.test.app.dokku.me"
assert_http_success "customtemplate.dokku.me"
} }
@test "(nginx-vhosts) nginx:build-config (no global VHOST and domains:add)" { @test "(nginx-vhosts) nginx:build-config (no global VHOST and domains:add)" {
+3 -3
View File
@@ -183,14 +183,14 @@ cat<<EOF > $DOKKU_ROOT/$APP/nginx.conf.template
server { server {
listen [::]:\$NGINX_PORT; listen [::]:\$NGINX_PORT;
listen \$NGINX_PORT; listen \$NGINX_PORT;
server_name \$NOSSL_SERVER_NAME; server_name \$NOSSL_SERVER_NAME customssltemplate.dokku.me;
return 301 https://\\\$host:\$NGINX_SSL_PORT\\\$request_uri; return 301 https://\\\$host:\$NGINX_SSL_PORT\\\$request_uri;
} }
server { server {
listen [::]:\$NGINX_SSL_PORT ssl spdy; listen [::]:\$NGINX_SSL_PORT ssl spdy;
listen \$NGINX_SSL_PORT ssl spdy; listen \$NGINX_SSL_PORT ssl spdy;
server_name \$SSL_SERVER_NAME; server_name \$SSL_SERVER_NAME customssltemplate.dokku.me;
\$SSL_DIRECTIVES \$SSL_DIRECTIVES
keepalive_timeout 70; keepalive_timeout 70;
@@ -218,7 +218,7 @@ cat<<EOF > $DOKKU_ROOT/$APP/nginx.conf.template
server { server {
listen [::]:\$NGINX_PORT; listen [::]:\$NGINX_PORT;
listen \$NGINX_PORT; listen \$NGINX_PORT;
server_name \$NOSSL_SERVER_NAME; server_name \$NOSSL_SERVER_NAME customtemplate.dokku.me;
location / { location / {
proxy_pass http://\$APP; proxy_pass http://\$APP;