From 7e84b544677b659bcc5fb4b7a4b17a3a40646921 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Tue, 17 Nov 2020 10:16:40 +0100 Subject: [PATCH] Add config variables in order to create links outside of a request context --- .env.tpl | 9 +++++++++ docker-compose.traefik.yml | 4 ++-- web/app/templates/tasks/email/notification.html.j2 | 2 +- web/app/templates/tasks/email/notification.txt.j2 | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.env.tpl b/.env.tpl index e7c2cea7..d88f1da5 100644 --- a/.env.tpl +++ b/.env.tpl @@ -31,10 +31,19 @@ HOST_DOCKER_GID= # Flask # # https://flask.palletsprojects.com/en/1.1.x/config/ # ################################################################################ +# CHOOSE ONE: http, https +# DEFAULT: http +# PREFERRED_URL_SCHEME= + # DEFAULT: hard to guess string # HINT: Use this bash command `python -c "import uuid; print(uuid.uuid4().hex)"` # SECRET_KEY= +# Example: nopaque.example.com nopaque.example.com:5000 +# HINT: If your instance is publicly available on a different Port then 80/443, +# you will have to add this to the server name +SERVER_NAME= + # CHOOSE ONE: False, True # DEFAULT: False # HINT: Set to true if you redirect http to https diff --git a/docker-compose.traefik.yml b/docker-compose.traefik.yml index 5cefda8f..afd688f9 100644 --- a/docker-compose.traefik.yml +++ b/docker-compose.traefik.yml @@ -18,13 +18,13 @@ services: - "traefik.http.middlewares.nopaque-header.headers.customrequestheaders.X-Forwarded-Proto=http" - "traefik.http.routers.nopaque.entrypoints=web" - "traefik.http.routers.nopaque.middlewares=nopaque-header, redirect-to-https@file" - - "traefik.http.routers.nopaque.rule=Host(``)" + - "traefik.http.routers.nopaque.rule=Host(`${SERVER_NAME}`)" ### ### ### ### - "traefik.http.middlewares.nopaque-secure-header.headers.customrequestheaders.X-Forwarded-Proto=https" - "traefik.http.routers.nopaque-secure.entrypoints=web-secure" - "traefik.http.routers.nopaque-secure.middlewares=hsts-header@file, nopaque-secure-header" - - "traefik.http.routers.nopaque-secure.rule=Host(``)" + - "traefik.http.routers.nopaque-secure.rule=Host(`${SERVER_NAME}`)" - "traefik.http.routers.nopaque-secure.tls.certresolver=" - "traefik.http.routers.nopaque-secure.tls.options=intermediate@file" ### ### diff --git a/web/app/templates/tasks/email/notification.html.j2 b/web/app/templates/tasks/email/notification.html.j2 index 4e25ab4e..1aac0bf7 100644 --- a/web/app/templates/tasks/email/notification.html.j2 +++ b/web/app/templates/tasks/email/notification.html.j2 @@ -3,6 +3,6 @@

The status of your Job "{{ job.title }}" has changed!

It is now {{ job.status }}!

-

You can access your Job here:

+

You can access your Job here: {{ url_for('jobs.job', job_id=job.id) }}

Kind regards!
Your nopaque team

diff --git a/web/app/templates/tasks/email/notification.txt.j2 b/web/app/templates/tasks/email/notification.txt.j2 index 7634ee3a..03012b3e 100644 --- a/web/app/templates/tasks/email/notification.txt.j2 +++ b/web/app/templates/tasks/email/notification.txt.j2 @@ -3,7 +3,7 @@ Dear {{ job.creator.username }}, The status of your Job "{{ job.title }}" has changed! It is now {{ job.status }}! -You can access your Job here: +You can access your Job here: {{ url_for('jobs.job', job_id=job.id) }} Kind regards! Your nopaque team