自从升级到 django 1.5 后,我的日志显示了几个SuspiciousOperation
带有文本的异常:
Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): <my server's ip>
这真的是一个“可疑”请求,还是ALLOWED_HOSTS
除了我的域名之外,我是否应该始终在设置中包含我的服务器的 IP 地址?知道什么会发出请求HTTP_HOST = "ip address"
而不是HTTP_HOST = "domain name"
?
这是请求环境:
{'HTTP_ACCEPT_ENCODING': "'identity'",
'HTTP_CONNECTION': "'close'",
'HTTP_HOST': "'168.62.208.14'",
'HTTP_X_FORWARDED_PROTOCOL': "'https'",
'HTTP_X_REAL_IP': "'176.10.35.241'",
'HTTP_X_SCHEME': "'https'",
'PATH_INFO': "u'/'",
'QUERY_STRING': "''",
'RAW_URI': "'/'",
'REMOTE_ADDR': "'127.0.0.1'",
'REMOTE_PORT': "'45068'",
'REQUEST_METHOD': "'GET'",
'SCRIPT_NAME': "u''",
'SERVER_NAME': "'168.62.208.14'",
'SERVER_PORT': "'80'",
'SERVER_PROTOCOL': "'HTTP/1.0'",
'SERVER_SOFTWARE': "'gunicorn/0.14.6'",
'gunicorn.socket': "'<socket._socketobject object at 0x7ab3b40>'",
'wsgi.errors': '"<open file \'<stderr>\', mode \'w\' at 0x7f0c94810270>"',
'wsgi.file_wrapper': "'<class gunicorn.http.wsgi.FileWrapper at 0x34eec80>'",
'wsgi.input': "'<gunicorn.http.body.Body object at 0x2a0bf10>'",
'wsgi.multiprocess': 'False',
'wsgi.multithread': 'False',
'wsgi.run_once': 'False',
'wsgi.url_scheme': "'http'",
'wsgi.version': '[1, 0]'}