rabianr/laravel-ip-restrictions

Laravel 的 IP 限制中间件

1.2 2022-01-31 07:55 UTC

This package is auto-updated.

Last update: 2024-09-29 05:56:59 UTC


README

安装

composer require rabianr/laravel-ip-restrictions

配置

发布配置以将文件复制到您的配置目录

php artisan vendor:publish --tag="iprestrictions"

使用方法

iprestrictions 中间件设置到任何需要基本身份验证的路由。

config/iprestrictions.php 配置文件中定义 IP 地址。

'whitelist' => array_merge([
    '1.1.1.1',
], array_filter(explode(',', env('IPRESTRICTIONS_WHITELIST', '')))),

或者在 .env 文件中

IPRESTRICTIONS_WHITELIST=1.1.1.1,1.1.1.2