Move nginx:import-ssl to certs:add
This commit is contained in:
@@ -15,7 +15,7 @@ To enable TLS connections to to one of your applications, do the following:
|
||||
* 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
|
||||
* Install the pair for your app, like this: ssh dokku@ip-of-your-dokku-server certs:add < 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).
|
||||
|
||||
@@ -46,7 +46,7 @@ Beware that if you enable the header and a subsequent deploy of your application
|
||||
You can import ssl certificates via tarball using the following command:
|
||||
|
||||
``` bash
|
||||
dokku nginx:import-ssl myapp < archive-of-certs.tar
|
||||
dokku certs:add myapp < archive-of-certs.tar
|
||||
```
|
||||
|
||||
This archive should is expanded via `tar xvf`. It should contain `server.crt` and `server.key`.
|
||||
@@ -152,7 +152,7 @@ On subsequent deploys, the nginx virtualhost will be discarded. This is useful w
|
||||
|
||||
> New as of 0.3.10
|
||||
|
||||
The domains plugin allows you to specify custom domains for applications. This plugin is aware of any ssl certificates that are imported via `nginx:import-ssl`. Be aware that setting `NO_VHOST` will override any custom domains.
|
||||
The domains plugin allows you to specify custom domains for applications. This plugin is aware of any ssl certificates that are imported via `certs:add`. Be aware that setting `NO_VHOST` will override any custom domains.
|
||||
|
||||
Custom domains are also backed up via the built-in `backup` plugin
|
||||
|
||||
|
||||
@@ -4,6 +4,43 @@ source "$(dirname $0)/../common/functions"
|
||||
source "$(dirname $0)/functions"
|
||||
|
||||
case "$1" in
|
||||
certs:add)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
verify_app_name "$2"
|
||||
[[ -t 0 ]] && echo "Tar archive containing server.crt and server.key expected on stdin" && exit 1
|
||||
APP="$2"
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
cd $TEMP_DIR
|
||||
tar xvf - <&0
|
||||
|
||||
CRT_FILE_SEARCH=$(find . -type f -name "*.crt")
|
||||
CRT_FILE_COUNT=$(printf "%s" "$CRT_FILE_SEARCH" | grep -c '^')
|
||||
if [[ $CRT_FILE_COUNT -lt 1 ]]; then
|
||||
echo "Tar archive is missing .crt file" && exit 1
|
||||
elif [[ $CRT_FILE_COUNT -gt 1 ]]; then
|
||||
echo "Tar archive contains more than one .crt file" && exit 1
|
||||
else
|
||||
CRT_FILE=$CRT_FILE_SEARCH
|
||||
fi
|
||||
|
||||
KEY_FILE_SEARCH=$(find . -type f -name "*.key")
|
||||
KEY_FILE_COUNT=$(printf "%s" "$KEY_FILE_SEARCH" | grep -c '^')
|
||||
if [[ $KEY_FILE_COUNT -lt 1 ]]; then
|
||||
echo "Tar archive is missing .key file" && exit 1
|
||||
elif [[ $KEY_FILE_COUNT -gt 1 ]]; then
|
||||
echo "Tar archive contains more than one .key file" && exit 1
|
||||
else
|
||||
KEY_FILE=$KEY_FILE_SEARCH
|
||||
fi
|
||||
|
||||
mkdir -p "$DOKKU_ROOT/$APP/tls"
|
||||
mv "$CRT_FILE" "$DOKKU_ROOT/$APP/tls/server.crt"
|
||||
mv "$KEY_FILE" "$DOKKU_ROOT/$APP/tls/server.key"
|
||||
cd $DOKKU_ROOT
|
||||
rm -rf $TEMP_DIR
|
||||
dokku nginx:build-config $APP
|
||||
;;
|
||||
certs:generate)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
verify_app_name "$2"
|
||||
@@ -91,6 +128,7 @@ case "$1" in
|
||||
|
||||
help | certs:help)
|
||||
cat && cat<<EOF
|
||||
certs:add <app>, Add an ssl endpoint to an app. Imports a tarball from stdin; should contain server.crt and server.key
|
||||
certs:generate <app> DOMAIN, Generate a key and certificate signing request (and self-signed certificate)
|
||||
certs:info <app>, Show certificate information for an ssl endpoint.
|
||||
certs:remove <app>, Remove an SSL Endpoint from an app.
|
||||
|
||||
@@ -159,49 +159,8 @@ EOF
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
nginx:import-ssl)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
verify_app_name "$2"
|
||||
[[ -t 0 ]] && echo "Tar archive containing server.crt and server.key expected on stdin" && exit 1
|
||||
APP="$2"
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
cd $TEMP_DIR
|
||||
tar xvf - <&0
|
||||
|
||||
CRT_FILE_SEARCH=$(find . -type f -name "*.crt")
|
||||
CRT_FILE_COUNT=$(printf "%s" "$CRT_FILE_SEARCH" | grep -c '^')
|
||||
if [[ $CRT_FILE_COUNT -lt 1 ]]; then
|
||||
echo "Tar archive is missing .crt file" && exit 1
|
||||
elif [[ $CRT_FILE_COUNT -gt 1 ]]; then
|
||||
echo "Tar archive contains more than one .crt file" && exit 1
|
||||
else
|
||||
CRT_FILE=$CRT_FILE_SEARCH
|
||||
fi
|
||||
|
||||
KEY_FILE_SEARCH=$(find . -type f -name "*.key")
|
||||
KEY_FILE_COUNT=$(printf "%s" "$KEY_FILE_SEARCH" | grep -c '^')
|
||||
if [[ $KEY_FILE_COUNT -lt 1 ]]; then
|
||||
echo "Tar archive is missing .key file" && exit 1
|
||||
elif [[ $KEY_FILE_COUNT -gt 1 ]]; then
|
||||
echo "Tar archive contains more than one .key file" && exit 1
|
||||
else
|
||||
KEY_FILE=$KEY_FILE_SEARCH
|
||||
fi
|
||||
|
||||
|
||||
mkdir -p "$DOKKU_ROOT/$APP/tls"
|
||||
mv "$CRT_FILE" "$DOKKU_ROOT/$APP/tls/server.crt"
|
||||
mv "$KEY_FILE" "$DOKKU_ROOT/$APP/tls/server.key"
|
||||
cd $DOKKU_ROOT
|
||||
rm -rf $TEMP_DIR
|
||||
dokku nginx:build-config $APP
|
||||
;;
|
||||
|
||||
help | nginx:help)
|
||||
cat && cat<<EOF
|
||||
nginx:import-ssl <app>, Imports a tarball from stdin; should contain server.crt and server.key
|
||||
nginx:build-config <app>, (Re)builds nginx config for given app
|
||||
EOF
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user