I have this error once or twice a month (??) in a production site which is up and running smoothly for months.
Invalid HTTP_HOST header: u'/home/dev/whatever/whatever.sock:'. The domain name provided is not valid according to RFC 1034/1035.
Request repr():<WSGIRequestpath:/,GET:<QueryDict: {}>,POST:<QueryDict: {}>,COOKIES:{},META:{'HTTP_CONNECTION': 'close','HTTP_X_FORWARDED_FOR': '94.XXX.51.168','HTTP_X_FORWARDED_PROTO': 'https','HTTP_X_REAL_IP': '94.XXX.51.168','PATH_INFO': u'/','QUERY_STRING': '','RAW_URI': '/','REMOTE_ADDR': '','REQUEST_METHOD': 'GET','SCRIPT_NAME': u'','SERVER_NAME': '/home/dev/whatever/whatever.sock','SERVER_PORT': '','SERVER_PROTOCOL': 'HTTP/1.0','SERVER_SOFTWARE': 'gunicorn/19.4.5','gunicorn.socket': <socket._socketobject object at 0x7fabff8ce4b0>,'wsgi.errors': <gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7fabff956810>,'wsgi.file_wrapper': <class 'gunicorn.http.wsgi.FileWrapper'>,'wsgi.input': <newrelic.api.web_transaction._WSGIInputWrapper object at 0x7fabff956b90>,'wsgi.multiprocess': True,'wsgi.multithread': False,'wsgi.run_once': False,'wsgi.url_scheme': 'https','wsgi.version': (1, 0)}>
NGINX is configured to accept only the domain itself.
upstream django_whatever_server { server unix:/home/dev/whatever/whatever.sock fail_timeout=0;}proxy_cache_path /var/cache/nginx/whatever/ levels=1:2 keys_zone=cache_whatever:5m max_size=1g inactive=60m;server { listen 80; server_name www.whatever.com.br whatever.com; return 301 https://www.whatever.com.br$request_uri;}server { listen 443 ssl; server_name www.whatever.com.br localhost 127.0.0.1; keepalive_timeout 70; ssl_session_cache shared:SSL:20m; ssl_session_timeout 20m; ssl_certificate BLAH; ssl_certificate_key BLAH; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers BLAH; ssl_prefer_server_ciphers on; ssl_dhparam BLAH; ssl_stapling on; ssl_stapling_verify on; ssl_trusted_certificate BLAH; resolver 8.8.8.8 8.8.4.4 valid=300s; location / { client_max_body_size 12m; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_cache cache_whatever; proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; proxy_cache_min_uses 1; proxy_cache_lock on; proxy_cache_bypass $arg_nocache; add_header X-BLAH-Cache-Status $upstream_cache_status; proxy_pass http://django_whatever_server; }}server { listen 80 default_server; server_name _ ""; return 444;}
I have other websites running the same NGINX config, except for the HTTPS rules.
WHY on Earth HTTP_HOST == my socket file real path? Why once/twice a month? (earlier reports showed bing useragent)