diff --git a/docker-compose.env.example b/docker-compose.env.example index 51332437d..50c1690be 100644 --- a/docker-compose.env.example +++ b/docker-compose.env.example @@ -17,6 +17,10 @@ # default language used when guessing the language from the OCR output. # PAPERLESS_OCR_LANGUAGES=deu ita +# Set Paperless to use SSL for the web interface. +# Enabling this will require ssl.key and ssl.cert files in paperless' data directory. +# PAPERLESS_USE_SSL=false + # You can change the default user and group id to a custom one # USERMAP_UID=1000 # USERMAP_GID=1000 diff --git a/docs/setup.rst b/docs/setup.rst index ed9a0b49f..9a371f889 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -193,6 +193,13 @@ Docker Method container and thus the one of the consumption directory. Furthermore, you can change the id of the default user as well using ``USERMAP_UID``. + ``PAPERLESS_USE_SSL`` + If you want Paperless to use SSL for the user interface, set this variable + to ``true``. You also need to copy your certificate and key to the ``data`` + directory, named ``ssl.cert`` and ``ssl.key``. + This is not an ideal solution and, if possible, a reverse proxy with nginx + is preferred. + 6. Run ``docker-compose up -d``. This will create and start the necessary containers. 7. To be able to login, you will need a super user. To create it, execute the @@ -206,7 +213,8 @@ Docker Method e-mail address and finally a password. 8. The default ``docker-compose.yml`` exports the webserver on your local port 8000. If you haven't adapted this, you should now be able to visit your - `Paperless webserver`_ at ``http://127.0.0.1:8000``. You can login with the + `Paperless webserver`_ at ``http://127.0.0.1:8000`` (or + ``https://127.0.0.1:8000`` if you enabled SSL). You can login with the user and password you just created. 9. Add files to consumption directory the way you prefer to. Following are two possible options: diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index 14f431b64..d2451720e 100644 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -101,8 +101,18 @@ if [[ "$1" != "/"* ]]; then if [[ "$1" = "gunicorn" ]]; then shift + EXTRA_PARAMS="" + SSL_KEY_PATH="/usr/src/paperless/data/ssl.key" + SSL_CERT_PATH="/usr/src/paperless/data/ssl.cert" + if [ "${PAPERLESS_USE_SSL}" = "true" ]; then + if [ -f "${SSL_KEY_PATH}" ] && [ -f "${SSL_CERT_PATH}" ]; then + EXTRA_PARAMS="--certfile=${SSL_CERT_PATH} --keyfile=${SSL_KEY_PATH}" + else + echo "Error: Could not find certfile in ${SSL_CERT_PATH} or keyfile in ${SSL_KEY_PATH}, but \$PAPERLESS_USE_SSL is true. Starting without SSL enabled." + fi + fi cd /usr/src/paperless/src/ && \ - exec sudo -HEu paperless /usr/bin/gunicorn -c /usr/src/paperless/gunicorn.conf "$@" paperless.wsgi + exec sudo -HEu paperless /usr/bin/gunicorn -c /usr/src/paperless/gunicorn.conf ${EXTRA_PARAMS} "$@" paperless.wsgi else exec sudo -HEu paperless "/usr/src/paperless/src/manage.py" "$@" fi