我在Ubuntu 16.04上运行nginx、gunicorn和wagtail。我没有使用virtualenv。nginx和gunicorn似乎都工作得很好,但当我在浏览器(比如myweb.com)中进入我的域时,我得到了一个不允许的主机错误。
编辑:具体的错误消息是(使用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'
页面上有更多的信息,但我认为这就是所有可能与问题相关的信息