User Guide


The ipfilter directive adds the ability to allow or block requests based on the client's IP address.

Full documentation


Filter a specific IP or a CIDR range.
ipfilter / { rule block ip 2001:db8::/122 }

caddy will block any clients with IPs that fall into one of these two ranges and 2001:db8::/122 , or a client that has an IP of explicitly.

Filter clients based on their Country ISO Code
ipfilter / { rule allow database /data/GeoLite.mmdb country US JP }

with that in your Caddyfile caddy will only serve users from the United States or Japan.

filtering with country codes requires a local copy of the Geo database, can be downloaded for free from MaxMind.

Define a block page
ipfilter / { rule allow blockpage default.html ip 2e80::20:f8ff:fe31:77cf }

caddy will serve only these 2 IPs, eveyone else will get default.html.

Multiple paths
ipfilter /notglobal /secret { rule allow ip }

Only serve under /notglobal and /secret.

Multiple blocks
ipfilter / { rule allow ip } ipfilter /webhook { rule allow ip }

You can use as many ipfilter blocks as you please, the above says: block everyone but, Unless it falls in and requesting a path in /webhook.

Related Links

Access the full documentation for this plugin off-site:

Plugin Help

Get help from the maintainers of the http.ipfilter plugin:

Plugin Website

Visit http.ipfilter's website for more information:

Plugin Author: Abdulelah
Last Updated: 25 Mar 2017, 1:58 PM
This plugin is independent of the Caddy project and is not endorsed or maintained by Caddy developers. Use at your own risk. Do not file issues for this plugin on Caddy's bug tracker.