我有Django(1.6.10),Nginx(1.7.9)和uwsgi(1.9.17.1-debian)代理。 有时我在电子邮件中看到这样的错误:
DisallowedHost: Invalid HTTP_HOST header: '*.example.com'.
(example.com是我的域名,点之间的星号非常混乱)
我有带子域的服务器(超过2000)所以我这样配置了我的Django:
ALLOWED_HOSTS = ['example.com', '.example.com']
Nginx以这种方式配置:
server {
listen 80;
listen 443 ssl;
server_name example.com *.example.com;
location / {
uwsgi_pass unix:///tmp/jsp.sock;
include uwsgi_params;
}
...
从追溯我只能得到这个错误发生在ie6上,在安全(https)版本的网站上(我支持http和https),但我无法重现它安装虚拟机。
<WSGIRequest
path:/,
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{},
META:{'CONTENT_LENGTH': '',
'CONTENT_TYPE': '',
'DOCUMENT_ROOT': '/etc/nginx/html',
'HTTPS': 'on',
'HTTP_ACCEPT_ENCODING': 'none',
'HTTP_CONNECTION': 'close',
'HTTP_HOST': '*.example.com',
'HTTP_USER_AGENT': 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.2)',
'PATH_INFO': u'/',
'QUERY_STRING': '',
'REMOTE_ADDR': '<ip here>',
'REMOTE_PORT': '39282',
'REQUEST_METHOD': 'GET',
'REQUEST_URI': '/',
u'SCRIPT_NAME': u'',
'SERVER_NAME': 'example.com',
'SERVER_PORT': '443',
'SERVER_PROTOCOL': 'HTTP/1.1',
'UWSGI_APPID': '*.foundjob.ru|',
'uwsgi.node': 'Ubuntu-1304-raring-64-minimal',
'uwsgi.version': '1.9.17.1-debian',
'wsgi.errors': <open file 'wsgi_errors', mode 'w' at 0x7fbcfd0f14b0>,
'wsgi.file_wrapper': <built-in function uwsgi_sendfile>,
'wsgi.input': <uwsgi._Input object at 0x7fbd025bae28>,
'wsgi.multiprocess': True,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'https',
'wsgi.version': (1, 0)}>