Add Redis TLS support for Heroku

base.py(286~287)
- CELERY_BROKER_USE_SSL
- CELERY_REDIS_BACKEND_USE_SSL

production.py(51~54)
- REDIS_SSL
- Set to default=False, no impact on existing environments

You only need to set REDIS_SSL=True in Heroku environment
Add only new options without modifying existing settings
This commit is contained in:
qwerrrqw 2024-11-06 17:48:55 +09:00
parent f8954e8a47
commit 5682ead8a0
3 changed files with 11 additions and 3 deletions

View File

@ -181,7 +181,7 @@ wheels = [
[[package]]
name = "cookiecutter-django"
version = "2024.10.24"
version = "2024.11.5"
source = { virtual = "." }
dependencies = [
{ name = "binaryornot" },
@ -204,7 +204,7 @@ dependencies = [
{ name = "tox-uv" },
]
[package.dependency-groups]
[package.dev-dependencies]
docs = [
{ name = "myst-parser" },
{ name = "sphinx" },
@ -234,7 +234,7 @@ requires-dist = [
{ name = "tox-uv", specifier = ">=1.11.2" },
]
[package.metadata.dependency-groups]
[package.metadata.requires-dev]
docs = [
{ name = "myst-parser", specifier = ">=4" },
{ name = "sphinx", specifier = ">=8.0.2" },

View File

@ -283,6 +283,9 @@ LOGGING = {
}
REDIS_URL = env("REDIS_URL", default="redis://{% if cookiecutter.use_docker == 'y' %}redis{%else%}localhost{% endif %}:6379/0")
CELERY_BROKER_USE_SSL = env.bool("CELERY_BROKER_USE_SSL", default=False)
CELERY_REDIS_BACKEND_USE_SSL = env.bool("CELERY_REDIS_BACKEND_USE_SSL", default=False)
{% if cookiecutter.use_celery == 'y' -%}
# Celery

View File

@ -48,6 +48,11 @@ CACHES = {
},
}
REDIS_SSL = env.bool("REDIS_SSL", default=False)
if REDIS_SSL:
CACHES["default"]["OPTIONS"]["CONNECTION_POOL_CLASS"] = "redis.connection.SSLConnection"
CACHES["default"]["OPTIONS"]["SSL_CERT_REQS"] = None
# SECURITY
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header