无效的http_host标头

问题:无效的http_host标头

我正在尝试使用Django框架开发网站,并使用DigitalOcean.com启动并将必要的文件部署到django-project中。

我必须将静态文件包含到Django项目中,并且在收集静态文件后,我尝试刷新我的ip

我包括了我用来创建网站的教程。 https://www.pythonprogramming.net/django-web-server-publish-tutorial/

我收到以下错误:

/无效的HTTP_HOST标头中的DisallowedHost:“ 198.211.99.20”。您可能需要将u’198.211.99.20’添加到ALLOWED_HOSTS。

有人可以帮我解决这个问题吗?这是我第一个使用Django框架的网站。

I am trying to develop a website using Django framework and launched using DigitalOcean.com and deployed the necessary files into django-project.

I had to include static files into Django-project and After collecting static files, I tried to refresh my ip

I am including the tutorials which I have used to create the website. 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.

Can somebody help me to fix this ? This is my first website using Django framework.


回答 0

错误日志很简单。如它的建议,您需要 在设置中添加198.211.99.20ALLOWED_HOSTS

在您的项目settings.py文件中,设置ALLOWED_HOSTS如下:

ALLOWED_HOSTS = ['198.211.99.20', 'localhost', '127.0.0.1']

如需进一步阅读,请从这里阅读

The error log is straightforward. As it suggested,You need to add 198.211.99.20 to your ALLOWED_HOSTS setting.

In your project settings.py file,set ALLOWED_HOSTS like this :

ALLOWED_HOSTS = ['198.211.99.20', 'localhost', '127.0.0.1']

For further reading read from here.


回答 1

settings.py

ALLOWED_HOSTS = ['*']

settings.py

ALLOWED_HOSTS = ['*']