Remove Nginx-specific static and media serving, and serve media through Django using WhiteNoise and FileResponse.
This commit is contained in:
parent
aa348d2b04
commit
92e1336f80
6 changed files with 46 additions and 23 deletions
|
|
@ -46,6 +46,9 @@ ADMINS = [tuple(a.split(":")) for a in config("ADMINS", default="", cast=Csv())
|
|||
SESSION_COOKIE_SECURE = not DEBUG
|
||||
CSRF_COOKIE_SECURE = not DEBUG
|
||||
|
||||
# Trust Caddy's forwarded proto header
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
|
||||
# Remember HTTPS for 1 year
|
||||
SECURE_HSTS_SECONDS = 31536000
|
||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
||||
|
|
@ -77,6 +80,7 @@ if DEBUG:
|
|||
|
||||
MIDDLEWARE = [
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
|
|
@ -189,6 +193,18 @@ STATIC_ROOT = os.path.join(BASE_DIR, "static/")
|
|||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||
MEDIA_URL = "/media/"
|
||||
|
||||
STORAGES = {
|
||||
"default": {
|
||||
"BACKEND": "django.core.files.storage.FileSystemStorage",
|
||||
},
|
||||
"staticfiles": {
|
||||
"BACKEND": "photo21.storage.CompressedManifestStorage",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
WHITENOISE_MANIFEST_STRICT = False
|
||||
|
||||
LOCALE_PATHS = [os.path.join(BASE_DIR, "photo21/locale")]
|
||||
|
||||
FIXTURE_DIRS = [os.path.join(BASE_DIR, "photo21/fixtures")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue