Python 无效的 http_host 标头
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40582423/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Invalid http_host header
提问by Kathiravan Natarajan
I am trying to develop a website using Django framework and launched using DigitalOcean.com and deployed the necessary files into django-project.
我正在尝试使用 Django 框架开发一个网站,并使用 DigitalOcean.com 启动并将必要的文件部署到 django-project 中。
I had to include static files into Django-project and After collecting static files, I tried to refresh my ip
我不得不将静态文件包含到 Django 项目中,并且在收集静态文件后,我尝试刷新我的 ip
I am including the tutorials which I have used to create the website. https://www.pythonprogramming.net/django-web-server-publish-tutorial/
我包括我用来创建网站的教程。 https://www.pythonprogramming.net/django-web-server-publish-tutorial/
I am getting the following error :
我收到以下错误:
DisallowedHost at / Invalid HTTP_HOST header: '198.211.99.20'. You may need to add u'198.211.99.20' to ALLOWED_HOSTS.
DisallowedHost at / Invalid HTTP_HOST 标头:'198.211.99.20'。您可能需要将 u'198.211.99.20' 添加到 ALLOWED_HOSTS。
Can somebody help me to fix this ? This is my first website using Django framework.
有人可以帮我解决这个问题吗?这是我第一个使用 Django 框架的网站。
回答by Prakhar Trivedi
The error log is straightforward. As it suggested,You need to add 198.211.99.20to your ALLOWED_HOSTS
setting.
错误日志很简单。正如它所建议的,您需要将198.211.99.20添加 到您的ALLOWED_HOSTS
设置中。
In your project settings.py file,set ALLOWED_HOSTS
like this :
在您的项目 settings.py 文件中,设置ALLOWED_HOSTS
如下:
ALLOWED_HOSTS = ['198.211.99.20', 'localhost', '127.0.0.1']
For further reading read from here.
如需进一步阅读,请 阅读此处。
回答by George Poliovei
settings.py
设置.py
ALLOWED_HOSTS = ['*']