我有一个项目现在运行了大约六个月,一周前它开始提出随机的SuspiciousOperation异常,好奇的是所有这些都发生在夜间。 OO
如果我尝试浏览它并且无法复制错误,页面工作正常。
这是Django自动发送给我的报告:
这是Django自动发送给我的报告:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 92, in get_response
response = middleware_method(request)
File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py", line 57, in process_request
host = request.get_host()
File "/usr/local/lib/python2.7/dist-packages/django/http/request.py", line 72, in get_host
"Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): %s" % host)
SuspiciousOperation: Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): onlyfonts.net.
<WSGIRequest
path:/,
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{},
META:{'CONTENT_LENGTH': '',
'CONTENT_TYPE': '',
'HTTP_ACCEPT': '*/*',
'HTTP_ACCEPT_ENCODING': 'gzip',
'HTTP_CF_CONNECTING_IP': '2400:8900::f03c:91ff:feae:eff7',
'HTTP_CF_IPCOUNTRY': 'XX',
'HTTP_CF_RAY': '10e5f8a0424d018d-NRT',
'HTTP_CF_VISITOR': '{"scheme":"http"}',
'HTTP_CONNECTION': 'close',
'HTTP_HOST': 'onlyfonts.net.',
'HTTP_USER_AGENT': 'curl/7.26.0',
'HTTP_X_FORWARDED_FOR': '2400:8900::f03c:91ff:feae:eff7, 108.162.226.18',
'HTTP_X_FORWARDED_PROTO': 'http',
'PATH_INFO': u'/',
'QUERY_STRING': '',
'RAW_URI': '/',
'REMOTE_ADDR': '108.162.226.18',
'REMOTE_PORT': '80',
'REQUEST_METHOD': 'GET',
'SCRIPT_NAME': u'',
'SERVER_NAME': 'onlyfonts.net.',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.0',
'SERVER_SOFTWARE': 'gunicorn/0.12.2',
'gunicorn.socket': <socket._socketobject object at 0x94ba764>,
'wsgi.errors': <open file '<stderr>', mode 'w' at 0xb72fc0d0>,
'wsgi.file_wrapper': <class gunicorn.http.wsgi.FileWrapper at 0x8af826c>,
'wsgi.input': <gunicorn.http.body.Body object at 0x94b61ec>,
'wsgi.multiprocess': True,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)}>
是的,我的域名被添加到ALLOWED_HOSTS,正如我所提到的,页面工作正常。
谢谢!