gpt4 book ai didi

django - EC2 上允许的 Django 主机设置

转载 作者:行者123 更新时间:2023-12-04 13:33:02 25 4
gpt4 key购买 nike

我刚刚部署到 Amazon EC2 bitnami djnago 堆栈,但我在 settings.py 文件中的 ALLOWED_HOSTS 设置方面遇到了问题。我不确定要使用什么主机名或在哪里可以找到它。我试过内部IP,外部IP,本地主机,域名。唯一让 500 个错误页面停止的事情是:

ALLOWED_HOSTS = ['*']

但是,这是一个安全问题。我错过了什么?

最佳答案

将其设置为 -

ALLOWED_HOSTS = [
'.yourdomain.com'
]

哪里 yourdomain.com是您用来访问它的域名。

documentation说——

Values in this list can be fully qualified names (e.g. 'www.example.com'), in which case they will be matched against the request’s Host header exactly (case-insensitive, not including port). A value beginning with a period can be used as a subdomain wildcard: '.example.com' will match example.com, www.example.com, and any other subdomain of example.com.



当您将其设置为 www.yourdomain.com 时,肯定有其他子域的请求,除了 www .这造成了麻烦。我不能确切地说,因为我没有那么多信息。

关于django - EC2 上允许的 Django 主机设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16466761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com