From 71b79da262d613fb7951daf8a0da54dd1ff29e5f Mon Sep 17 00:00:00 2001 From: Assaf Arkin Date: Mon, 23 Mar 2015 13:34:03 -0700 Subject: [PATCH 1/5] CHANGED extract nginx.conf.template from project --- plugins/nginx-vhosts/commands | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index 3600965e0..079774ad0 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -49,6 +49,9 @@ case "$1" in shopt -u nullglob fi + DOKKU_APP_CONTAINER_ID=$(< "$DOKKU_ROOT/$APP/CONTAINER") + docker cp "$DOKKU_APP_CONTAINER_ID:/app/nginx.conf" "$APP_NGINX_TEMPLATE" 2> /dev/null || true + [[ -f "$DOKKU_ROOT/ENV" ]] && source $DOKKU_ROOT/ENV [[ -f "$DOKKU_ROOT/$APP/ENV" ]] && source $DOKKU_ROOT/$APP/ENV [[ -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' From 379a2e8908229b175ce9087d42544b8675573ca5 Mon Sep 17 00:00:00 2001 From: Assaf Arkin Date: Wed, 25 Mar 2015 10:45:35 -0700 Subject: [PATCH 2/5] Added documentation --- docs/nginx.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/nginx.md b/docs/nginx.md index 154dc3635..b3f1d4707 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -10,15 +10,14 @@ Dokku provides easy TLS/SPDY support out of the box. This can be done app-by-app To enable TLS connections to to one of your applications, do the following: -* Create a key file and a cert file. +* Create a key file and a cert file. * You can find detailed steps for generating a self-signed certificate at https://devcenter.heroku.com/articles/ssl-certificate-self * If you are not paranoid and need it just for a DEV or STAGING app, you can use http://www.selfsignedcertificate.com/ to generate your 2 files more easily. * Rename your files to server.key and server.crt * tar these 2 files together, *without* subdirectories. Example: tar cvf cert-key.tar server.crt server.key * Install the pair for your app, like this: ssh dokku@ip-of-your-dokku-server nginx:import-ssl < cert-key.tar -You will need to repeat the steps above for each domain used to serve your app. You can't simply create -a single tar with all key/cert files in it (see https://github.com/progrium/dokku/issues/1195). +You will need to repeat the steps above for each domain used to serve your app. You can't simply create a single tar with all key/cert files in it (see https://github.com/progrium/dokku/issues/1195). ### All Subdomains @@ -54,11 +53,15 @@ This archive should is expanded via `tar xvf`. It should contain `server.crt` an ## Customizing the nginx configuration -> New as of 0.3.10 +> New as of 0.3.17. -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, you should copy the existing template - ssl or non-ssl - into your `$DOKKU_ROOT/$APP` directory at the file `nginx.conf.template`. If you followed the default installation path, the original templates are found in `/var/lib/dokku/plugins/nginx-vhosts/templates/nginx{.ssl,}.conf.template` . +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, you should copy the existing template - ssl or non-ssl - into your application repository's root directory as the file `nginx.conf.template`. The next time you deploy, Nginx will use your template instead of the default. -For instance - assuming defaults - to customize the nginx template in use for the `myapp` application, create a file at `/home/dokku/myapp/nginx.conf.template` with the following contents: +> New as of 0.3.10. + +You may also place this file on disk at the path `/home/dokku/myapp/nginx.conf.template`. If placed on disk on the dokku server, the template file **must** be owned by the user `dokku:dokku`. + +For instance - assuming defaults - to customize the nginx template in use for the `myapp` application, create the file `nginx.conf.template` in your repo or on disk with the with the following contents: ``` server { @@ -86,7 +89,7 @@ server { } ``` -The above is a sample http configuration that adds an `X-Served-By` header to requests. The template file **must** be owned by the user `dokku:dokku`. +The above is a sample http configuration that adds an `X-Served-By` header to requests. A few tips for custom nginx templates: From 6895dd993611a4d12b2e87ef8af7f5f888015545 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 11 Jul 2015 16:29:25 -0400 Subject: [PATCH 3/5] Use get_container_ids method to retrieve container for nginx conf --- plugins/nginx-vhosts/commands | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index 079774ad0..e1ba8bebb 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -49,8 +49,13 @@ case "$1" in shopt -u nullglob fi - DOKKU_APP_CONTAINER_ID=$(< "$DOKKU_ROOT/$APP/CONTAINER") - docker cp "$DOKKU_APP_CONTAINER_ID:/app/nginx.conf" "$APP_NGINX_TEMPLATE" 2> /dev/null || true + DOKKU_APP_CIDS=$(get_container_ids $APP) + if [[ -n $DOKKU_APP_CIDS ]]; then + for DOKKU_APP_CID in $DOKKU_APP_CIDS; do + docker cp "$DOKKU_APP_CID:/app/nginx.conf" "$APP_NGINX_TEMPLATE" 2> /dev/null || true + break + done + fi [[ -f "$DOKKU_ROOT/ENV" ]] && source $DOKKU_ROOT/ENV [[ -f "$DOKKU_ROOT/$APP/ENV" ]] && source $DOKKU_ROOT/$APP/ENV From 007946f52a5fd73028fa2976a54a328791bef381 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Jul 2015 20:02:29 -0400 Subject: [PATCH 4/5] Use simplified method for retrieving a container id --- plugins/nginx-vhosts/commands | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index e1ba8bebb..03a4ceaa1 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -49,13 +49,8 @@ case "$1" in shopt -u nullglob fi - DOKKU_APP_CIDS=$(get_container_ids $APP) - if [[ -n $DOKKU_APP_CIDS ]]; then - for DOKKU_APP_CID in $DOKKU_APP_CIDS; do - docker cp "$DOKKU_APP_CID:/app/nginx.conf" "$APP_NGINX_TEMPLATE" 2> /dev/null || true - break - done - fi + DOKKU_APP_CIDS=($(get_container_ids $APP)) + docker cp "${DOKKU_APP_CID[0]}:/app/nginx.conf" "$APP_NGINX_TEMPLATE" 2> /dev/null || true [[ -f "$DOKKU_ROOT/ENV" ]] && source $DOKKU_ROOT/ENV [[ -f "$DOKKU_ROOT/$APP/ENV" ]] && source $DOKKU_ROOT/$APP/ENV From ca1b17ea8da34b18cc3a7a985806c1531e59f774 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 12 Jul 2015 20:06:21 -0400 Subject: [PATCH 5/5] Use nginx.conf.template as the template name --- plugins/nginx-vhosts/commands | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index 03a4ceaa1..e7e602a2b 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -50,7 +50,7 @@ case "$1" in fi DOKKU_APP_CIDS=($(get_container_ids $APP)) - docker cp "${DOKKU_APP_CID[0]}:/app/nginx.conf" "$APP_NGINX_TEMPLATE" 2> /dev/null || true + docker cp "${DOKKU_APP_CID[0]}:/app/nginx.conf.template" "$APP_NGINX_TEMPLATE" 2> /dev/null || true [[ -f "$DOKKU_ROOT/ENV" ]] && source $DOKKU_ROOT/ENV [[ -f "$DOKKU_ROOT/$APP/ENV" ]] && source $DOKKU_ROOT/$APP/ENV