Skip to content

Commit

Permalink
Merge pull request #102 from Prescrypto/feature/enable_redis_tls
Browse files Browse the repository at this point in the history
REXCHAIN Implement support for rediss (TLS) connections
  • Loading branch information
ebarojas authored Oct 25, 2024
2 parents 80ecec3 + 2defbf2 commit 03b6ab3
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions rexchain/rexchain/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import ast
import dj_database_url

# To parse REDIS_URL
from urllib.parse import urlparse

"""
Django settings for RexChain project.
Generated by 'django-admin startproject' using Django 1.11.3.
Generated by 'django-admin startproject' using Django 1.11.3. (oldddddd)
"""

Expand Down Expand Up @@ -193,20 +196,32 @@
# Fixtures DIR for testings
FIXTURE_DIRS = [os.path.join(BASE_DIR, 'fixtures')]

# Define REDIS_URL
REDIS_URL = os.getenv("REDIS_URL", 'redis://localhost:6379/0')
# Redis Cache
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": os.getenv('REDIS_TEMPORARY_URL', 'redis://localhost:6379/0'),
"LOCATION": REDIS_URL,
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"CONNECTION_POOL_KWARGS": {
# config for pool connections
"max_connections": 10
"max_connections": 10 # Note, we should review this.
}
}
}
}

# Parsing URL in order to single out TSL connections
parsed_url = urlparse(REDIS_URL)

# Append SSL/TLS configuration if using rediss:// (TLS)
if parsed_url.scheme == 'rediss':
CACHES['default']['OPTIONS']['CONNECTION_POOL_KWARGS'].update({
'ssl_cert_reqs': None # or ssl.CERT_REQUIRED with proper CA certs
})

# Redis Config
RQ_QUEUES = {
'default': {
Expand Down

0 comments on commit 03b6ab3

Please sign in to comment.