Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Route Blocker

Laravel Route Blocker Laravel Package

skydiver/laravel-route-blocker

Block routes in Laravel with a simple, configurable middleware layer. Restrict access by IP, environment, or custom rules, and return clean 403 responses. Lightweight and easy to drop into any Laravel app.

View on GitHub
Deep Wiki
Context7

Block routes by IP

Frequently asked questions about Laravel Route Blocker
How do I install and register skydiver/laravel-route-blocker?
Install it with Composer, pinning an exact version rather than a floating constraint so a surprise release cannot change blocking behavior in production. Publish the package config file and seed it with the addresses you want to deny, then register the middleware either globally in the HTTP kernel or as a named alias you attach to specific route groups. There is no database dependency, queue, or event footprint to wire up, so the whole setup is config plus one registration line.
Which Laravel and PHP versions does this package support?
The package's own composer.json constraints are the source of truth, so check them against your application's Laravel and PHP versions before committing. Single-purpose packages with a small maintainer base often lag behind new Laravel majors, so budget for the possibility of forking or vendoring the middleware. After enabling it, run your full test suite plus a smoke test of auth and public routes.
Does the middleware work correctly behind a load balancer or CDN?
It depends entirely on your trusted proxy configuration. If TrustProxies is misconfigured behind an ALB or CDN, the middleware either sees the proxy address and blocks everyone or trusts an attacker-supplied X-Forwarded-For header and blocks no one. Validate client IP resolution in staging behind a proxy setup that mirrors production before promoting the middleware to the global stack.
Can I block an IP range or use CIDR notation with this package?
The package is deliberately narrow in scope, and CIDR, subnet, and wildcard handling are not clearly documented, so verify support in the source before relying on it. If you need subnet-level blocking, a WAF, load balancer ACL, or a small custom middleware is a more dependable place to enforce it. Test any range entries in staging to confirm they match as expected rather than assuming.
What response does a blocked request receive — 403, 404, or a redirect?
The package returns a clean 403 response, which is the conventional signal for a denied IP. Whether the status code, body, or view is configurable should be confirmed against the source for your pinned version. If you would rather hide the existence of a route, a 404 response is often preferable and would require customization.
Can I apply the middleware to only one route group instead of globally?
Yes. Register it as a named middleware alias and attach it to a specific route group such as your login routes or a public API instead of the global stack. A scoped rollout is safer because you can observe the false-positive rate on a low-risk surface before protecting everything. Moving to global registration later is a one-line change once you trust the blocklist.
Can I allowlist trusted IPs so they override the blocklist?
Allowlist precedence is not guaranteed and should be verified in the package source before you depend on it. Shared NAT and corporate egress IPs mean a blocked address can take out legitimate users, so an explicit allowlist that wins over blocks matters for offices and internal teams. If the package lacks that behavior, wrap the middleware or keep those routes behind a separate group.
Is a config-file blocklist fast enough to stop credential stuffing or scraper waves?
Not as a primary control. The blocklist lives in config, so every change means a deploy or a config cache clear, which is far too slow for fast-moving abuse. Treat this package as an application-layer backstop and keep rate limiting, throttling, and edge protections in front for real-time mitigation.
How is this different from Laravel's throttle middleware or a WAF?
Throttle limits request rates per key, while this package denies specific IPs outright before the request reaches a controller. A WAF or load balancer ACL operates at the edge and blocks traffic before it hits your application servers, which is generally the stronger control. The value here is a lightweight, config-as-code backstop that ships with your app and needs no extra infrastructure.
Is skydiver/laravel-route-blocker actively maintained and safe to use in production?
It has a modest community footprint, which implies a small maintainer base and limited third-party testing. Pin an exact version in composer.json and plan for the possibility of forking or vendoring the middleware if releases lag behind new Laravel versions. The codebase is small enough to review directly, and you should cover the middleware with your own tests before relying on it.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings