|
17 | 17 | DEBUG = False |
18 | 18 | SECRET_KEY = os.environ["SECRET_KEY"] |
19 | 19 | ALLOWED_HOSTS = [ |
| 20 | + "0.0.0.0", |
20 | 21 | "127.0.0.1", |
| 22 | + "localhost", |
21 | 23 | "pythonsd.org", |
22 | 24 | "www.pythonsd.org", |
23 | 25 | "pythonsd.com", |
|
45 | 47 | # https://docs.djangoproject.com/en/3.2/ref/settings/#caches |
46 | 48 | # http://niwinz.github.io/django-redis/ |
47 | 49 | # -------------------------------------------------------------------------- |
48 | | -CACHES = { |
49 | | - "default": { |
50 | | - "BACKEND": "django_redis.cache.RedisCache", |
51 | | - "LOCATION": os.environ["REDIS_URL"], |
52 | | - "OPTIONS": { |
53 | | - "CLIENT_CLASS": "django_redis.client.DefaultClient", |
54 | | - "IGNORE_EXCEPTIONS": True, |
55 | | - }, |
| 50 | +if "REDIS_URL" in os.environ: |
| 51 | + CACHES = { |
| 52 | + "default": { |
| 53 | + "BACKEND": "django_redis.cache.RedisCache", |
| 54 | + "LOCATION": os.environ["REDIS_URL"], |
| 55 | + "OPTIONS": { |
| 56 | + "CLIENT_CLASS": "django_redis.client.DefaultClient", |
| 57 | + "IGNORE_EXCEPTIONS": True, |
| 58 | + }, |
| 59 | + } |
56 | 60 | } |
57 | | -} |
58 | 61 |
|
59 | 62 |
|
60 | 63 | # Security |
61 | 64 | # https://docs.djangoproject.com/en/3.2/topics/security/ |
62 | 65 | # https://devcenter.heroku.com/articles/http-routing#heroku-headers |
63 | 66 | # -------------------------------------------------------------------------- |
64 | | -SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") |
65 | | -SECURE_SSL_HOST = os.environ.get("SECURE_SSL_HOST") |
66 | | -SECURE_SSL_REDIRECT = True |
67 | | -SESSION_COOKIE_SECURE = True |
68 | | -SESSION_COOKIE_HTTPONLY = True |
69 | | -CSRF_COOKIE_SECURE = True |
70 | | -CSRF_COOKIE_HTTPONLY = True |
71 | | -SECURE_HSTS_SECONDS = 60 * 60 * 24 * 365 |
72 | | -SECURE_HSTS_INCLUDE_SUBDOMAINS = True |
73 | | -SECURE_HSTS_PRELOAD = True |
74 | | -SECURE_CONTENT_TYPE_NOSNIFF = True |
75 | | -SECURE_BROWSER_XSS_FILTER = True |
76 | | -X_FRAME_OPTIONS = "DENY" |
| 67 | +if "SECURE_SSL_HOST" in os.environ: |
| 68 | + SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") |
| 69 | + SECURE_SSL_HOST = os.environ.get("SECURE_SSL_HOST") |
| 70 | + SECURE_SSL_REDIRECT = True |
| 71 | + SESSION_COOKIE_SECURE = True |
| 72 | + SESSION_COOKIE_HTTPONLY = True |
| 73 | + CSRF_COOKIE_SECURE = True |
| 74 | + CSRF_COOKIE_HTTPONLY = True |
| 75 | + SECURE_HSTS_SECONDS = 60 * 60 * 24 * 365 |
| 76 | + SECURE_HSTS_INCLUDE_SUBDOMAINS = True |
| 77 | + SECURE_HSTS_PRELOAD = True |
| 78 | + SECURE_CONTENT_TYPE_NOSNIFF = True |
| 79 | + SECURE_BROWSER_XSS_FILTER = True |
| 80 | + X_FRAME_OPTIONS = "DENY" |
77 | 81 |
|
78 | 82 | # If set, all requests to other domains redirect to this one |
79 | 83 | # https://github.com/dabapps/django-enforce-host |
|
0 commit comments