1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
From: Jonas Meurer <jonas@freesources.org>
Date: Sat, 23 Jan 2021 21:16:26 +0100
Subject: Adjust settings.py for Debian mailman3-web
* Disable debugging mode.
* Disable all allauth socialaccount providers for privacy reasons.
* Set postgresql as default database engine.
* Enable 'USE_X_FORWARDED_HOST'.
* Adjust 'STATIC_ROOT' and 'STATIC_URL' paths.
* Adjust 'DEFAULT_FROM_EMAIL' and 'SERVER_EMAIL'.
* Use smtp email backend per default to send mails.
* Set 'ACCOUNT_DEFAULT_HTTP_PROTOCOL' to 'https'.
* Change logging level for most logging channels to 'INFO'.
* Set queue polling inteval vor django-q cluster to 5 seconds (defaults
to 0.2 seconds) to decrease the database load.
* Remove lessc from COMPRESS_COMPILERS, mailman3 django projects don't
use/require less at all.
* Uncomment COMPRESS_COMPILERS altogether. Hyperkitty in Debian compiles
scss files at build time, so no sass compiler is needed at runtime.
Forwarded: not-needed
Last-Update: 2021-01-23
---
mailman-suite_project/settings.py | 109 ++++++++++++++++++++------------------
1 file changed, 56 insertions(+), 53 deletions(-)
diff --git a/mailman-suite_project/settings.py b/mailman-suite_project/settings.py
index e5cc413..0a06a3f 100644
--- a/mailman-suite_project/settings.py
+++ b/mailman-suite_project/settings.py
@@ -34,7 +34,7 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
SECRET_KEY = 'change-this-on-your-production-server'
# SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
+DEBUG = False
ADMINS = (
('Mailman Suite Admin', 'root@localhost'),
@@ -85,13 +85,13 @@ INSTALLED_APPS = (
'allauth.account',
'allauth.socialaccount',
'django_mailman3.lib.auth.fedora',
- 'allauth.socialaccount.providers.openid',
- 'allauth.socialaccount.providers.github',
- 'allauth.socialaccount.providers.gitlab',
- 'allauth.socialaccount.providers.google',
+ # 'allauth.socialaccount.providers.openid',
+ # 'allauth.socialaccount.providers.github',
+ # 'allauth.socialaccount.providers.gitlab',
+ # 'allauth.socialaccount.providers.google',
# 'allauth.socialaccount.providers.facebook',
- 'allauth.socialaccount.providers.twitter',
- 'allauth.socialaccount.providers.stackexchange',
+ # 'allauth.socialaccount.providers.twitter',
+ # 'allauth.socialaccount.providers.stackexchange',
)
@@ -145,9 +145,9 @@ WSGI_APPLICATION = 'wsgi.application'
DATABASES = {
'default': {
# Use 'sqlite3', 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
- 'ENGINE': 'django.db.backends.sqlite3',
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
# DB name or path to database file if using sqlite3.
- 'NAME': os.path.join(BASE_DIR, 'mailmansuite.db'),
+ 'NAME': 'mailman3web',
# The following settings are not used with sqlite3:
'USER': 'mailmansuite',
'PASSWORD': 'mmpass',
@@ -176,7 +176,7 @@ DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# If you're behind a proxy, use the X-Forwarded-Host header
# See https://docs.djangoproject.com/en/1.8/ref/settings/#use-x-forwarded-host
-# USE_X_FORWARDED_HOST = True
+USE_X_FORWARDED_HOST = True
# And if your proxy does your SSL encoding for you, set SECURE_PROXY_SSL_HEADER
# https://docs.djangoproject.com/en/1.8/ref/settings/#secure-proxy-ssl-header
@@ -241,11 +241,11 @@ USE_TZ = True
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
-STATIC_ROOT = os.path.join(BASE_DIR, 'static')
+STATIC_ROOT = '/var/lib/mailman3/web/static'
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
-STATIC_URL = '/static/'
+STATIC_URL = '/mailman3/static/'
# Additional locations of static files
STATICFILES_DIRS = (
@@ -269,23 +269,24 @@ LOGIN_URL = 'account_login'
LOGIN_REDIRECT_URL = 'list_index'
LOGOUT_URL = 'account_logout'
+HOSTNAME = 'localhost.local'
# If you enable internal authentication, this is the address that the emails
# will appear to be coming from. Make sure you set a valid domain name,
# otherwise the emails may get rejected.
# https://docs.djangoproject.com/en/1.8/ref/settings/#default-from-email
# DEFAULT_FROM_EMAIL = "mailing-lists@you-domain.org"
-DEFAULT_FROM_EMAIL = 'postorius@localhost.local'
+DEFAULT_FROM_EMAIL = 'postorius@{}'.format(HOSTNAME)
# If you enable email reporting for error messages, this is where those emails
# will appear to be coming from. Make sure you set a valid domain name,
# otherwise the emails may get rejected.
# https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-SERVER_EMAIL
# SERVER_EMAIL = 'root@your-domain.org'
-SERVER_EMAIL = 'root@localhost.local'
+SERVER_EMAIL = 'root@{}'.format(HOSTNAME)
# Change this when you have a real email backend
-EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
+EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# Compatibility with Bootstrap 3
from django.contrib.messages import constants as messages # flake8: noqa
@@ -307,35 +308,35 @@ ACCOUNT_AUTHENTICATION_METHOD = "username_email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
# You probably want https in production, but this is a dev setup file
-ACCOUNT_DEFAULT_HTTP_PROTOCOL = "http"
+ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_EMAIL_UNKNOWN_ACCOUNTS = False
SOCIALACCOUNT_PROVIDERS = {
- 'openid': {
- 'SERVERS': [
- dict(id='yahoo',
- name='Yahoo',
- openid_url='http://me.yahoo.com'),
- ],
- },
- 'google': {
- 'SCOPE': ['profile', 'email'],
- 'AUTH_PARAMS': {'access_type': 'online'},
- },
- 'facebook': {
- 'METHOD': 'oauth2',
- 'SCOPE': ['email'],
- 'FIELDS': [
- 'email',
- 'name',
- 'first_name',
- 'last_name',
- 'locale',
- 'timezone',
- ],
- 'VERSION': 'v2.4',
- },
+ #'openid': {
+ # 'SERVERS': [
+ # dict(id='yahoo',
+ # name='Yahoo',
+ # openid_url='http://me.yahoo.com'),
+ # ],
+ #},
+ #'google': {
+ # 'SCOPE': ['profile', 'email'],
+ # 'AUTH_PARAMS': {'access_type': 'online'},
+ #},
+ #'facebook': {
+ # 'METHOD': 'oauth2',
+ # 'SCOPE': ['email'],
+ # 'FIELDS': [
+ # 'email',
+ # 'name',
+ # 'first_name',
+ # 'last_name',
+ # 'locale',
+ # 'timezone',
+ # ],
+ # 'VERSION': 'v2.4',
+ #},
}
@@ -361,11 +362,11 @@ SOCIALACCOUNT_PROVIDERS = {
# django-compressor
# https://pypi.python.org/pypi/django_compressor
#
-COMPRESS_PRECOMPILERS = (
- ('text/less', 'lessc {infile} {outfile}'),
- ('text/x-scss', 'sassc -t compressed {infile} {outfile}'),
- ('text/x-sass', 'sassc -t compressed {infile} {outfile}'),
-)
+#COMPRESS_PRECOMPILERS = (
+# ('text/less', 'lessc {infile} {outfile}'),
+# ('text/x-scss', 'sassc -t compressed {infile} {outfile}'),
+# ('text/x-sass', 'sassc -t compressed {infile} {outfile}'),
+#)
# On a production setup, setting COMPRESS_OFFLINE to True will bring a
# significant performance improvement, as CSS files will not need to be
# recompiled on each requests. It means running an additional "compress"
@@ -383,7 +384,7 @@ COMPRESS_PRECOMPILERS = (
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
- 'PATH': os.path.join(BASE_DIR, "fulltext_index"),
+ 'PATH': '/var/lib/mailman3/web/fulltext_index',
# You can also use the Xapian engine, it's faster and more accurate,
# but requires another library.
# http://django-haystack.readthedocs.io/en/v2.4.1/installing_search_engines.html#xapian
@@ -401,6 +402,7 @@ Q_CLUSTER = {
'save_limit': 100,
'orm': 'default',
'retry': 360,
+ 'poll': 5,
}
@@ -425,9 +427,9 @@ LOGGING = {
},
'file':{
'level': 'INFO',
- #'class': 'logging.handlers.RotatingFileHandler',
- 'class': 'logging.handlers.WatchedFileHandler',
- 'filename': os.path.join(BASE_DIR, 'logs', 'mailmansuite.log'),
+ 'class': 'logging.handlers.RotatingFileHandler',
+ #'class': 'logging.handlers.WatchedFileHandler',
+ 'filename': '/var/log/mailman3/web/mailman-web.log',
'formatter': 'verbose',
},
'console': {
@@ -438,22 +440,23 @@ LOGGING = {
'loggers': {
'django.request': {
'handlers': ['mail_admins', 'file'],
- 'level': 'ERROR',
+ 'level': 'INFO',
'propagate': True,
},
'django': {
'handlers': ['file'],
- 'level': 'ERROR',
+ 'level': 'INFO',
'propagate': True,
},
'hyperkitty': {
'handlers': ['file'],
- 'level': 'DEBUG',
+ 'level': 'INFO',
'propagate': True,
},
'postorius': {
- 'handlers': ['console', 'file'],
+ 'handlers': ['file'],
'level': 'INFO',
+ 'propagate': True,
},
},
'formatters': {
|