Django Invalid HTTP_HOST header hatası çözümü

Django 216 views Markdown

Django projenizi bir alan adı ile yayınlarken aşağıdaki hatayı alıyorsanız sebebi HTTP servisindeki proxy edilen HOST bilgisinin hatalı olması. Yani arada unicorn gibi bir servis var ise NGINx veya Apache proxy ile uvicorna yönlendirirken HOST bilgisini hatalı gönderiyor.

Invalid HTTP_HOST header: '\\alanadi.com'. The domain name provided is not valid according to RFC 1034/1035.

 

proxy_set_header Host '$http_host';
 '$http_host' olan kısma ek işaretler eklendi ise \\ gibi bu url uvicorna gönderilir ve URL kuralları eşleşmesi sağlanamaz.

 

  NGINX örnek:

 

location / {
proxy_set_header Host '$http_host';
proxy_set_header X-Forwarded-For '$proxy_add_x_forwarded_for';
proxy_set_header X-Forwarded-Proto '$http_x_forwarded_proto';
proxy_redirect off;
proxy_pass http://notifytube_django3;
proxy_connect_timeout 500;
proxy_read_timeout 600;
}
NOT: NGINX servisini yeniden başlatmayı unutmayın.

 

 
Was this helpful?

Thanks for your feedback!

Still Need Help?

The support team is here around the clock for anything you can't find in the knowledge base.