在Django的1.5,你可以設置允許主機:Django ALLOWED_HOSTS相當於禁止的主機?
ALLOWED_HOSTS = [
'.example.com', # Allow domain and subdomains
'.example.com.', # Also allow FQDN and subdomains
]
是否有禁止主機的相同呢?即我提供一個IP列表來自動拒絕?
在Django的1.5,你可以設置允許主機:Django ALLOWED_HOSTS相當於禁止的主機?
ALLOWED_HOSTS = [
'.example.com', # Allow domain and subdomains
'.example.com.', # Also allow FQDN and subdomains
]
是否有禁止主機的相同呢?即我提供一個IP列表來自動拒絕?
您可以通過一箇中間件,作爲文檔說:
的「*」將匹配任何值;在這種情況下,您有責任提供您自己的Host頭的驗證(可能在中間件中;如果是這樣的話,該中間件必須首先在MIDDLEWARE_CLASSES中列出)。
不,沒有爲此目的的設置沒有equivanlent。
您可以創建自己的中間件:http://djangosnippets.org/snippets/725/http://djangosnippets.org/snippets/744/