mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
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:
@@ -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:
|
||||
|
||||
- Copy the existing template - ssl or non-ssl - into your application repository's root directory as the file `nginx.conf.template`.
|
||||
- Create a template file in `/home/dokku/APP` named one of the following:
|
||||
- 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:
|
||||
- `nginx.conf.template` (since 0.3.10)
|
||||
- `nginx.conf.ssl_terminated.template` (since 0.4.0)
|
||||
- `nginx.ssl.conf.template` (since 0.4.2)
|
||||
|
||||
@@ -157,7 +157,9 @@ nginx_build_config() {
|
||||
fi
|
||||
|
||||
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'
|
||||
|
||||
@@ -235,7 +237,7 @@ EOF
|
||||
|
||||
while read -r line; do
|
||||
[[ -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
|
||||
NOSSL_SERVER_NAME=$line
|
||||
eval "cat <<< \"$(< $NGINX_SSL_TEMPLATE)\" >> $NGINX_CONF"
|
||||
@@ -250,7 +252,7 @@ EOF
|
||||
|
||||
if [[ -n "$NONSSL_VHOSTS" ]]; then
|
||||
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"
|
||||
fi
|
||||
if [[ "$(is_app_vhost_enabled $APP)" == "false" ]] || ([[ -z "$NONSSL_VHOSTS" ]] && [[ -z "$SSL_VHOSTS" ]]); then
|
||||
|
||||
@@ -98,6 +98,7 @@ assert_error_log() {
|
||||
deploy_app
|
||||
assert_ssl_domain "wildcard1.dokku.me"
|
||||
assert_ssl_domain "wildcard2.dokku.me"
|
||||
assert_http_success "customssltemplate.dokku.me"
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (wildcard SSL & unrelated domain)" {
|
||||
@@ -125,6 +126,7 @@ assert_error_log() {
|
||||
custom_nginx_template
|
||||
deploy_app
|
||||
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)" {
|
||||
|
||||
@@ -183,14 +183,14 @@ cat<<EOF > $DOKKU_ROOT/$APP/nginx.conf.template
|
||||
server {
|
||||
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;
|
||||
}
|
||||
|
||||
server {
|
||||
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
|
||||
|
||||
keepalive_timeout 70;
|
||||
@@ -218,7 +218,7 @@ cat<<EOF > $DOKKU_ROOT/$APP/nginx.conf.template
|
||||
server {
|
||||
listen [::]:\$NGINX_PORT;
|
||||
listen \$NGINX_PORT;
|
||||
server_name \$NOSSL_SERVER_NAME;
|
||||
server_name \$NOSSL_SERVER_NAME customtemplate.dokku.me;
|
||||
|
||||
location / {
|
||||
proxy_pass http://\$APP;
|
||||
|
||||
Reference in New Issue
Block a user