https://github.com/abiosoft/caddy-inspect
HTTP Request Inspector for Caddy web server
https://github.com/abiosoft/caddy-inspect
caddy debugger inspector
Last synced: about 1 year ago
JSON representation
HTTP Request Inspector for Caddy web server
- Host: GitHub
- URL: https://github.com/abiosoft/caddy-inspect
- Owner: abiosoft
- License: mit
- Created: 2025-01-23T17:12:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-14T10:39:57.000Z (over 1 year ago)
- Last Synced: 2025-02-14T11:34:58.990Z (over 1 year ago)
- Topics: caddy, debugger, inspector
- Language: Go
- Homepage:
- Size: 2.45 MB
- Stars: 23
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# caddy-inspect
The Inspect plugin provides an easy way to inspect HTTP requests in Caddy.
The Caddyfile is already easy to write. The Inspect plugin takes it a step further by allowing you to place breakpoints in the Caddyfile and ascertain the behaviour of Caddy.

## Features
- Insert a breakpoint anywhere in the Caddyfile with the `inspect` keyword.
- Inspecting HTTP and Caddy contexts
- Intercepting and terminating HTTP requests and responses
- Works in the browser, zero setup required.
## Installation
```
xcaddy build --with github.com/abiosoft/caddy-inspect
```
## Getting Started
### Specify breakpoints in the Caddyfile
Place the `inspect` keyword anywhere an [HTTP directive](https://caddyserver.com/docs/caddyfile/directives#caddyfile-directives) is supported in the Caddyfile. The keyword can be specified multiple times.
```caddy
:8080
route /api {
rewrite /api/* /api/v1{uri}
inspect
...
}
```
### Start Caddy
Caddy can be started with the `--watch` flag to autoreload the Caddyfile on each modification.
```sh
caddy run --watch
```
### Access the Inspect console
Open http://localhost:2020 in the browser to access the console.
> [!NOTE]
> Another port would be assigned if `2020` is not available.
> The URL can be confirmed in the Caddy logs.
### Enjoy
Any HTTP request(s) made to a route containing the `inspect` keyword would pause the request and activate the console.
## Caveats
> [!CAUTION]
> This plugin is intended for development purposes only, sensitive information may be exposed if used in a production environment.
- The plugin is tailored towards Caddyfile config. However, JSON config can be used with limited experience.
- Due to the in-built [order of directives](https://caddyserver.com/docs/caddyfile/directives#directive-order) in Caddy, `inspect` is more predictable in a `route` block. Otherwise, it is ordered after the `encode` directive.
- The information displayed are read-only and cannot be modified.
- HTTP request and response bodies cannot be inspected. It is a deliberate limitation until there is a strong argument in favour.
- The plugin stemmed from a personal use-case. Feedbacks would be appreciated to accommodate more use-cases.
## Attribution
The Caddy logo is a trademark of Caddy Web Server.
## License
MIT
## Sponsoring
You can support the author by donating on [Github Sponsors](https://github.com/sponsors/abiosoft) or [Buy me a coffee](https://www.buymeacoffee.com/abiosoft).