Blocking Requests
Learn how to block requests in Caddy
Updated
Caddy is the web server that lives between your application and the outside world. It reverse proxies requests to your application, handles SSL, and serves static files. Thanks to Caddy, we can also customize how our applications handle requests.
For example, running a Ruby application that should never bother with .php requests? Update your app's Caddy routes to the following and any .php request paths will now return 404s without hitting your application.
@php path *.php
respond @php 404
%{default}
@php defines a Caddy matcher that handles requests that match *.php in the path.
respond is a Caddy directive and tells it to respond with a 404 for any @php matched requests.
%{default} is a variable that Hatchbox uses to inject the default Caddy routes for your application. This includes static file serving from the public directory, reverse proxying, etc.