Django + Daphne + Caddy +文件上传= 413错误


1

我有一个与Caddy一起部署,生产的Django Web应用程序。在制作中,我使用Caddy作为指向daphne的反向代理,指向我的Django应用程序。但是,当我尝试将文件上传到生产中的管理门户时,我收到413错误。在调试模式下,当我刚刚使用Django时,我没有收到此错误。有人有主意吗?这是我的Caddyfile:

0.0.0.0:2015
on startup daphne peptidedb.asgi:application &

header / {
  -Server

    # be sure to plan & test before enabling
    # Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"

    Referrer-Policy "same-origin"
    X-XSS-Protection "1; mode=block"
    X-Content-Type-Options "nosniff"

    # customize for your app
    #Content-Security-Policy "connect-src 'self'; default-src 'none'; font-src 'self'; form-action 'self'; frame-ancestors 'none'; img-src data: 'self'; object-src 'self'; style-src 'self'; script-src 'self';"
    X-Frame-Options "DENY"
}

proxy / localhost:8000 {
    transparent
    websocket
    except /static
}

limits 750000000

log / stdout "{combined}"

errors stdout

asgi.py

import os

from channels.routing import get_default_application
import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "peptidedb.settings")
django.setup()
application = get_default_application()

wsgi.py

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "peptidedb.settings")

application = get_wsgi_application()

Answers:


0

尝试添加

DATA_UPLOAD_MAX_MEMORY_SIZE = 21474836480 # value in bytes 20GB here

到您的settings.py

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.