How to disable Django's invalid HTTP_HOST error?

前端 未结 11 918
日久生厌
日久生厌 2020-12-04 10:12

Ever since I deployed a site running Django 1.7 alpha (checked out from Git), I\'ve been occasionally receiving error messages with titles like:

\"Inv

11条回答
  •  既然无缘
    2020-12-04 10:49

    You shouldn't be ignoring this error. Instead you should be denying the request before it reaches your Django backend. To deny requests with no HOST set you can use

    SetEnvIfNoCase Host .+ VALID_HOST
    Order Deny,Allow
    Deny from All
    Allow from env=VALID_HOST
    

    or force the match to a particular domain (example.com)

    SetEnvIfNoCase Host example\.com VALID_HOST
    Order Deny,Allow
    Deny from All
    Allow from env=VALID_HOST
    

提交回复
热议问题