diff --git a/defaults/main.yml b/defaults/main.yml index 1de2e595..f7fae687 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,4 @@ --- - openwisp2_python: python3 ansible_python_interpreter: /usr/bin/python3 openwisp2_network_topology: false @@ -72,6 +71,7 @@ openwisp2_redis_install: true openwisp2_redis_host: localhost openwisp2_redis_port: 6379 openwisp2_redis_cache_url: "redis://{{ openwisp2_redis_host }}:{{ openwisp2_redis_port }}/1" +openwisp2_redis_sessions_url: "redis://{{ openwisp2_redis_host }}:{{ openwisp2_redis_port }}/4" openwisp2_influxdb_install: true openwisp2_timeseries_database: backend: "openwisp_monitoring.db.backends.influxdb" diff --git a/docs/user/role-variables.rst b/docs/user/role-variables.rst index b88a5950..0809cad9 100644 --- a/docs/user/role-variables.rst +++ b/docs/user/role-variables.rst @@ -241,6 +241,7 @@ take a look at `the default values of these variables openwisp2_redis_host: localhost openwisp2_redis_port: 6379 openwisp2_redis_cache_url: "redis://{{ openwisp2_redis_host }}:{{ openwisp2_redis_port }}/1" + openwisp2_redis_sessions_url: "redis://{{ openwisp2_redis_host }}:{{ openwisp2_redis_port }}/4" # the following options are required to configure influxdb which is used in openwisp-monitoring openwisp2_influxdb_install: true openwisp2_timeseries_database: diff --git a/templates/openwisp2/settings.py b/templates/openwisp2/settings.py index 861cf35b..f39a4c54 100644 --- a/templates/openwisp2/settings.py +++ b/templates/openwisp2/settings.py @@ -197,7 +197,7 @@ "default": { "BACKEND": "channels_redis.core.RedisChannelLayer", "CONFIG": { - "hosts": [("{{ openwisp2_redis_host }}", {{ openwisp2_redis_port }})], + "hosts": [f"redis://{{ openwisp2_redis_host }}:{{ openwisp2_redis_port }}/0"], "group_expiry": {{ openwisp2_daphne_websocket_timeout }}, }, }, @@ -358,11 +358,18 @@ "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", }, - } + }, + "sessions": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "{{ openwisp2_redis_sessions_url }}", + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + }, + }, } SESSION_ENGINE = "django.contrib.sessions.backends.cache" -SESSION_CACHE_ALIAS = "default" +SESSION_CACHE_ALIAS = "sessions" SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True