Skip to content

Commit

Permalink
Add support for secure Redis (TLS support) (#5526)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerrrqw authored Nov 21, 2024
1 parent d00cd42 commit 7fc33c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/3-deployment/deployment-on-heroku.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Run these commands to deploy the project to Heroku:
# Note: this is not a free plan
heroku addons:create heroku-postgresql:essential-0
# On Windows use double quotes for the time zone, e.g.
# heroku pg:backups schedule --at "02:00 America/Los_Angeles" DATABASE_URL
heroku pg:backups schedule --at '02:00 America/Los_Angeles' DATABASE_URL
Expand Down
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions {{cookiecutter.project_slug}}/config/settings/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# ruff: noqa: ERA001, E501
"""Base settings to build other settings files upon."""

{% if cookiecutter.use_celery == 'y' -%}
import ssl
{%- endif %}
from pathlib import Path

import environ
Expand Down Expand Up @@ -283,6 +286,7 @@
}

REDIS_URL = env("REDIS_URL", default="redis://{% if cookiecutter.use_docker == 'y' %}redis{%else%}localhost{% endif %}:6379/0")
REDIS_SSL = REDIS_URL.startswith("rediss://")

{% if cookiecutter.use_celery == 'y' -%}
# Celery
Expand All @@ -292,8 +296,12 @@
CELERY_TIMEZONE = TIME_ZONE
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-broker_url
CELERY_BROKER_URL = REDIS_URL
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#redis-backend-use-ssl
CELERY_BROKER_USE_SSL = {"ssl_cert_reqs": ssl.CERT_NONE} if REDIS_SSL else None
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_backend
CELERY_RESULT_BACKEND = REDIS_URL
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#redis-backend-use-ssl
CELERY_REDIS_BACKEND_USE_SSL = CELERY_BROKER_USE_SSL
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-extended
CELERY_RESULT_EXTENDED = True
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-backend-always-retry
Expand Down

0 comments on commit 7fc33c2

Please sign in to comment.