Django ALLOWED_HOSTS IPs range

前端 未结 5 1708
醉梦人生
醉梦人生 2021-01-31 08:46

Is there a way to set a range of ALLOWED_HOSTS IPs in django?

Something like this:

ALLOWED_HOSTS = [\'172.17.*.*\']
5条回答
  •  天涯浪人
    2021-01-31 09:45

    No, this is not currently possible. According to the docs, the following syntax is supported:

    ['www.example.com']  # Fully qualified domain
    ['.example.com']  # Subdomain wildcard, matches example.com and www.example.com 
    ['*']  # Matches anything
    

    If you look at the implementation of the validate_host method, you can see that using '*' by itself is allowed, but using * as a wildcard as part of a string (e.g. '172.17.*.*') is not supported.

提交回复
热议问题