Django ALLOWED_HOSTS IPs range

前端 未结 5 1706
醉梦人生
醉梦人生 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

    Mozilla have released a Python package called django-allow-cidr which is designed to solve exactly this problem.

    The announcement blog post explains that it's useful for things like health checks that don't have a Host header and just use an IP address.

    You would have to change your IP address '172.17.*.*' slightly to be a CIDR range like 172.17.0.0/16

提交回复
热议问题