Skip to content

Commit

Permalink
doc: modify ip restrictions plugin doc. (apache#1219)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayeshmantha Perera authored Mar 8, 2020
1 parent c8a00b1 commit 4ebfa24
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions doc/plugins/ip-restriction.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,58 @@ HTTP/1.1 403 Forbidden
{"message":"Your IP address is not allowed"}
```

## Change the restriction

When you want to change the whitelisted ip, it is very simple,
you can send the corresponding json configuration in the plugin configuration,
no need to restart the service, it will take effect immediately:

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/index.html",
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:1980": 1
}
},
"plugins": {
"ip-restriction": {
"whitelist": [
"127.0.0.2",
"113.74.26.106/24"
]
}
}
}'
```

## Test Plugin after restriction change

Requests to `127.0.0.2`:

```shell
$ curl http://127.0.0.2:9080/index.html
HTTP/1.1 200 OK
...
```

Requests to `127.0.0.1`:

```shell
$ curl http://127.0.0.1:9080/index.html -i
HTTP/1.1 403 Forbidden
...
{"message":"Your IP address is not allowed"}
```


## Disable Plugin

When you want to disable the `ip-restriction` plugin, it is very simple,
you can delete the corresponding json configuration in the plugin configuration,
no need to restart the service, it will take effect immediately:
you can delete the corresponding json configuration in the plugin configuration,
no need to restart the service, it will take effect immediately:

```shell
$ curl http://127.0.0.1:2379/v2/keys/apisix/routes/1 -X PUT -d value='
Expand Down

0 comments on commit 4ebfa24

Please sign in to comment.