Recently, I upgrade one of my django sites from http to https. However, after that, I continuously receive Invalid HTTP_HOST header
error email while before I never received such type of emails.
Here are some log messages:
[Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST header: '123.56.221.107'. You may need to add '123.56.221.107' to ALLOWED_HOSTS.
[Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST header: 'www.sgsrec.com'. You may need to add 'www.sgsrec.com' to ALLOWED_HOSTS.
[Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST header: 'sgsrec.com'. You may need to add 'sgsrec.com' to ALLOWED_HOSTS.
Report at /apple-app-site-association Invalid HTTP_HOST header: ‘sgsrec.com’. You may need to add ‘sgsrec.com’ to ALLOWED_HOSTS.
Invalid HTTP_HOST header: ‘www.pythonzh.cn’. You may need to add ‘www.pythonzh.cn’ to ALLOWED_HOSTS.
Report at / Invalid HTTP_HOST header: ‘www.pythonzh.cn’. You may need to add ‘www.pythonzh.cn’ to ALLOWED_HOSTS.
Request Method: GET Request URL: http://www.pythonzh.cn/ Django Version: 1.10.6
[Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST header: 'pythonzh.cn'. You may need to add 'pythonzh.cn' to ALLOWED_HOSTS.
What the strange thing is that I only change my blog site www.zmrenwu.com
nginx configuration, but seems all of my sites which hosted on 123.56.221.107 are effected.
Of cause, I set ALLOWED_HOSTS correctly:
ALLOWED_HOSTS = ['.zmrenwu.com']
ALLOWED_HOSTS = ['.sgsrec.com']
ALLOWED_HOSTS = ['.pythonzh.cn']
Nginx configuration of my blog site www.zmrenwu.com
:
server {
charset utf-8;
server_name zmrenwu.com www.zmrenwu.com;
listen 80;
return 301 https://www.zmrenwu.com$request_uri;
}
server {
charset utf-8;
server_name zmrenwu.com;
listen 443;
ssl on;
ssl_certificate /etc/ssl/1_www.zmrenwu.com_bundle.crt;
ssl_certificate_key /etc/ssl/2_www.zmrenwu.com.key;
return 301 https://www.zmrenwu.com$request_uri;
}
server {
charset utf-8;
listen 443;
server_name www.zmrenwu.com;
ssl on;
ssl_certificate /etc/ssl/1_www.zmrenwu.com_bundle.crt;
ssl_certificate_key /etc/ssl/2_www.zmrenwu.com.key;
location /static {
alias /home/yangxg/sites/zmrenwu.com/blogproject/static;
}
location /media {
alias /home/yangxg/sites/zmrenwu.com/blogproject/media;
}
location / {
proxy_set_header Host $host;
proxy_pass http://unix:/tmp/zmrenwu.com.socket;
Why that happened? And How could I solve this issue?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…