[英]django's ALLOWED_HOSTS throws error 500?
In my Django project's settings.py
for deployment i want mywebsite.com
to be the allowed hosts but putting it so throws the 500 error. 在我的Django项目的
settings.py
部署中,我希望mywebsite.com
成为允许的主机,但将其放置会引发500错误。
For production server when i use: 对于生产服务器,当我使用时:
ALLOWED_HOSTS = ['localhost', 'mywebsite.com']
It throws error 500 on every page. ALLOWED_HOSTS = ['localhost', 'mywebsite.com']
它在每个页面上引发错误500。
But if i change it to 但是如果我将其更改为
ALLOWED_HOSTS = ['*']
It works fine. ALLOWED_HOSTS = ['*']
正常工作。
I checked error.log
of nginx but there is not error logged. 我检查了
error.log
,但是没有记录错误。
But i guess its not safe to keep *
and i just want to keep mywebsite.com
or www.mywebsite.com
但是我想保留
*
不安全的,我只想保留mywebsite.com
或www.mywebsite.com
Please suggest why its throwing 500 error. 请提出为什么其抛出500错误。
Thanks 谢谢
Probably a duplicate of Allowed Host Setting for Django on EC2 where I can find the answer working fine (as they have accepted it). 可能是EC2上Django的“ 允许的主机设置”的重复项, 在这里我可以找到正确的答案(因为他们已经接受了)。 Please try it like and check if this works.
请尝试一下并检查是否可行。
ALLOWED_HOSTS = ['.mywebsite.com']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.