Wagtail忽略ALLOWED_HOSTS等设置

时间:2017-09-19 13:46:01

标签: django settings gunicorn wagtail

我在Ubuntu 16.04上运行nginx,gunicorn和wagtail。我没有使用virtualenv。 nginx和gunicorn似乎工作得很好但是当我在浏览器中访问我的域名时(让我们说myweb.com)我得到一个不允许的主机错误。

这似乎是一个简单的问题,但我已经将myweb.com添加为base.py中允许的主机,如下所示:ALLOWED_HOSTS = [' myweb.com']。它甚至在请求信息中说myweb.com是设置文件中允许的主机,但看起来像wagtail只是忽略了这一点。我也尝试在开发设置中关闭调试,但它仍然显示我的调试屏幕。

编辑:具体的错误消息是(使用myweb.com而不是实际域名):

DisallowedHost at /

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

Request Method:     GET

Request URL:    http://myweb.com/

Django Version:     1.11.5

Exception Type:     DisallowedHost

Exception Value:    Invalid HTTP_HOST header: 'myweb.com'. You may need to add 'myweb.com' to ALLOWED_HOSTS.

Exception Location:     /usr/local/lib/python3.5/dist-packages/django/http/request.py in get_host, line 113

Python Executable:  /usr/bin/python3

Python Version:     3.5.2

Python Path:    

['/home/fixgoats/myweb-root',
'/usr/local/bin',
'/usr/lib/python35.zip',
'/usr/lib/python3.5',
'/usr/lib/python3.5/plat-x86_64-linux-gnu',
'/usr/lib/python3.5/lib-dynload',
'/usr/local/lib/python3.5/dist-packages',
'/usr/lib/python3/dist-packages']

Traceback:
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner
41.             response = get_response(request)

File "/usr/local/lib/python3.5/dist-packages/django/utils/deprecation.py" in __call__
138.             response = self.process_request(request)

File "/usr/local/lib/python3.5/dist-packages/django/middleware/common.py" in process_request
57.         host = request.get_host()
File "/usr/local/lib/python3.5/dist-packages/django/http/request.py" in get_host
113.             raise DisallowedHost(msg)

Exception Type: DisallowedHost at /
Exception Value: Invalid HTTP_HOST header: 'myweb.com'. You may need to add 'myweb.com' to ALLOWED_HOSTS.

Request Information:

USER [unable to retrieve the current user]

GET     No GET data

POST    No POST data

FILES   No FILES data

Settings     Using settings module myweb.settings.dev

ALLOWED_HOSTS 'myweb.com'

页面上有更多信息,但我认为这可能是与问题相关的所有信息

1 个答案:

答案 0 :(得分:0)

Gunicorn需要重新启动。我不知道它是否应该像这样工作但是在我的设置上似乎总是需要重新启动Gunicorn以检测对项目文件所做的更改。