0

在 Caddy 反向代理后面使用 Django 会导致很多错误通知,如下所示:

Invalid HTTP_HOST header: 'www.msftncsi.com'. You may need to add 'www.msftncsi.com' to ALLOWED_HOSTS.

Caddy 不应该只将来自我自己域的请求传递给 Django 应用程序吗?相应的 Caddyfile 是:

mydummyyapp.com {
    # Use 'route' to allow this ordering. Otherwise, 'file_server' would need to come last.
    route {
        # Redirects just to be nice.
        redir /login /accounts/login permanent

        # Serve static files directly.
        file_server /static/* {
            root /home/apps/mydummyapp
        }

        # Pass on everything else to django/daphne.
        reverse_proxy 127.0.0.1:8000
     }
     log {
        output file /var/log/mydummyapp_access.log {
            roll_size 1gb
            roll_keep 5
            roll_keep_for 168h
        }
    }
}

我会假设不起源于的请求mydummyyapp.com甚至不会到达运行于127.0.0.1:8000. 天真和错误?

4

0 回答 0