Sentry Tunnel
A flexible Sentry tunnel middleware for Axum that helps bypass ad-blockers and content blockers by proxying Sentry error reports through your own domain.
Features
- Modular Architecture: Choose only the features you need
- Security: Validates DSN and project IDs to prevent abuse
- Flexible Integration: Router extension trait or standalone service
- Framework Agnostic Core: Use the core handler with any web framework
- Type-Safe: Built with Rust's type system for reliability
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Feature Flags
extension(default): Router extension trait for adding tunnel to existing Routerstandalone: Standalone service creation (depends onextension)service: Convenience feature enabling bothextensionandstandaloneutoipa: OpenAPI/utoipa support for documenting the tunnel endpoint (depends onextension)
To disable default features and use only the core:
[]
= { = "0.1", = false }
Usage
Method 1: Router Extension Trait (Recommended)
Add the Sentry tunnel directly to your existing Axum router:
use ;
use ;
async
Method 2: Standalone Service
Create a standalone Sentry tunnel service and nest it under a path:
use ;
async
Method 3: Core Handler (Framework Agnostic)
Use the core handler with any web framework:
use ;
use Arc;
async
Configuration
Using Builder Pattern
use SentryTunnelBuilder;
let config = new
.allow_project_id
.allow_project_id
.path
.timeout_secs
.build;
Direct Configuration
use SentryTunnelConfig;
let config = new
.with_path
.with_timeout;
Client Configuration
Configure your Sentry client to use the tunnel:
JavaScript/TypeScript
;
Python
Security
The tunnel validates:
- Hostname: Ensures requests only go to your configured Sentry host
- Project IDs: Only allows whitelisted project IDs
- DSN Format: Validates the DSN structure
This prevents:
- Unauthorized use of your tunnel
- Proxying requests to arbitrary domains
- Resource abuse
Examples
Run the examples:
# Extension trait example
# Standalone service example
# Both methods
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.