Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ VOLUME /etc/tiny-proxy
VOLUME /etc/ssl/tiny-proxy

ENTRYPOINT ["tiny-proxy"]
CMD ["-c", "/etc/tiny-proxy/config.caddy"]
CMD ["-c", "/etc/tiny-proxy/config.conf"]
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cargo install --path .

# Or build and run directly
cargo build --release
./target/release/tiny-proxy --config config.caddy
./target/release/tiny-proxy --config config.conf
```

### As Library
Expand All @@ -56,13 +56,13 @@ docker pull ghcr.io/denislituev/tiny-proxy:latest
# Run with a local config
docker run -d \
-p 8080:8080 \
-v $(pwd)/config.caddy:/etc/tiny-proxy/config.caddy:ro \
-v $(pwd)/config.conf:/etc/tiny-proxy/config.conf:ro \
ghcr.io/denislituev/tiny-proxy:latest

# With TLS
docker run -d \
-p 8443:8443 \
-v $(pwd)/config.caddy:/etc/tiny-proxy/config.caddy:ro \
-v $(pwd)/config.conf:/etc/tiny-proxy/config.conf:ro \
-v $(pwd)/certs:/etc/ssl/tiny-proxy:ro \
ghcr.io/denislituev/tiny-proxy:latest
```
Expand All @@ -76,7 +76,7 @@ services:
ports:
- "8080:8080"
volumes:
- ./config.caddy:/etc/tiny-proxy/config.caddy:ro
- ./config.conf:/etc/tiny-proxy/config.conf:ro
```

See [`docker-compose.yml`](docker-compose.yml) for a full example with TLS + echo backends.
Expand All @@ -99,15 +99,15 @@ Run as standalone server:

```bash
# Auto-detect listeners from config (recommended)
tiny-proxy --config config.caddy
tiny-proxy --config config.conf

# Or specify a single listen address
tiny-proxy --config config.caddy --addr 127.0.0.1:8080
tiny-proxy --config config.conf --addr 127.0.0.1:8080
```

#### CLI Arguments

- `--config, -c`: Path to configuration file (default: `./file.caddy`)
- `--config, -c`: Path to configuration file (default: `./file.conf`)
- `--addr, -a`: Optional. Bind a **single** listener on this address (plain `start()`).
When omitted, **auto-detect mode** (`start_all()`): one listener per site address in config.
TLS sites → HTTPS with SNI; non-TLS → HTTP. In auto-detect mode only, each TLS port also
Expand All @@ -124,7 +124,7 @@ use tiny_proxy::{Config, Proxy};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Load configuration from file
let config = Config::from_file("config.caddy")?;
let config = Config::from_file("config.conf")?;

// Create and start proxy
let proxy = Proxy::new(config);
Expand All @@ -144,7 +144,7 @@ use std::sync::Arc;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = Config::from_file("config.caddy")?;
let config = Config::from_file("config.conf")?;
let proxy = Arc::new(Proxy::new(config));

// Spawn proxy in background
Expand Down Expand Up @@ -179,7 +179,7 @@ use tokio::sync::RwLock;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = Config::from_file("config.caddy")?;
let config = Config::from_file("config.conf")?;
let proxy = Proxy::new(config);

// Get shared config handle for hot-reload
Expand All @@ -193,7 +193,7 @@ async fn main() -> anyhow::Result<()> {
});

// Update config at runtime — takes effect immediately
let new_config = Config::from_file("new-config.caddy")?;
let new_config = Config::from_file("new-config.conf")?;
{
let mut guard = config_handle.write().await;
*guard = new_config;
Expand All @@ -207,7 +207,7 @@ async fn main() -> anyhow::Result<()> {
Or use the built-in `update_config` method:

```rust
let new_config = Config::from_file("updated-config.caddy")?;
let new_config = Config::from_file("updated-config.conf")?;
proxy.update_config(new_config).await;
```

Expand Down Expand Up @@ -497,7 +497,7 @@ use tiny_proxy::api;
use std::sync::Arc;
use tokio::sync::RwLock;

let config = Arc::new(RwLock::new(Config::from_file("config.caddy")?));
let config = Arc::new(RwLock::new(Config::from_file("config.conf")?));
api::start_api_server("127.0.0.1:8081", config).await?;
```

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ services:
- "8080:8080"
- "8443:8443"
volumes:
- ./proxies/tiny-proxy.caddy:/etc/tiny-proxy/config.caddy:ro
- ./proxies/tiny-proxy.conf:/etc/tiny-proxy/config.conf:ro
- ./certs:/etc/ssl/tiny-proxy:ro
depends_on:
- backend
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Example stack: tiny-proxy (TLS + HTTP→HTTPS redirect) with internal echo backends.
#
# Backends are reachable only inside the compose network (no host ports).
# Config: config.caddy — HTTPS :8443, redirect :8080 (8443 - 443 + 80).
# Config: config.conf — HTTPS :8443, redirect :8080 (8443 - 443 + 80).
#
# Usage:
# mkdir -p certs
Expand All @@ -23,7 +23,7 @@ services:
- "8443:8443" # HTTPS (TLS termination)
- "8080:8080" # HTTP → HTTPS redirect
volumes:
- ./config.caddy:/etc/tiny-proxy/config.caddy:ro
- ./config.conf:/etc/tiny-proxy/config.conf:ro
- ./certs:/etc/ssl/tiny-proxy:ro
depends_on:
backend-users:
Expand Down
2 changes: 1 addition & 1 deletion examples/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async fn main() -> anyhow::Result<()> {
info!("Starting tiny-proxy background example");

// Load configuration from file
let config = Config::from_file("file.caddy")?;
let config = Config::from_file("file.conf")?;

info!("Loaded configuration for {} site(s)", config.sites.len());

Expand Down
4 changes: 2 additions & 2 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ async fn main() -> anyhow::Result<()> {
info!("Starting tiny-proxy library example");

// Load configuration from file
// Make sure file.caddy exists in the project root or provide a different path
let config = Config::from_file("file.caddy")?;
// Make sure file.conf exists in the project root or provide a different path
let config = Config::from_file("file.conf")?;

info!("Loaded configuration for {} site(s)", config.sites.len());

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/hot_reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! cargo run --example hot_reload
//! ```
//!
//! Then edit file.caddy while the proxy is running to see hot-reload in action.
//! Then edit file.conf while the proxy is running to see hot-reload in action.

use tiny_proxy::{Config, Proxy};
use tokio::time::{sleep, Duration};
Expand All @@ -28,7 +28,7 @@ async fn main() -> anyhow::Result<()> {

info!("Starting tiny-proxy hot-reload example");

let config_path = "file.caddy";
let config_path = "file.conf";

// Load initial configuration from file
let config = Config::from_file(config_path)?;
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn main() -> anyhow::Result<()> {

info!("Starting tiny-proxy TLS example");

let config = Config::from_file("examples/tls.caddy")?;
let config = Config::from_file("examples/tls.conf")?;
info!("Loaded configuration for {} site(s)", config.sites.len());

let proxy = Proxy::new(config);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//!
//! # #[tokio::main]
//! # async fn main() -> anyhow::Result<()> {
//! let config = Arc::new(RwLock::new(Config::from_file("config.caddy")?));
//! let config = Arc::new(RwLock::new(Config::from_file("config.conf")?));
//!
//! // Start the management API server
//! api::start_api_server("127.0.0.1:8081", config).await?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::error::Result;
/// # use std::sync::Arc;
/// # #[tokio::main]
/// # async fn main() -> anyhow::Result<()> {
/// let config = Arc::new(tokio::sync::RwLock::new(Config::from_file("config.caddy")?));
/// let config = Arc::new(tokio::sync::RwLock::new(Config::from_file("config.conf")?));
/// api::server::start_api_server("127.0.0.1:8081", config).await?;
/// # Ok(())
/// # }
Expand Down
2 changes: 1 addition & 1 deletion src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use clap::Parser;
#[command(author, version, about, long_about = None)]
pub struct Cli {
/// Path to configuration file (Caddy-like format)
#[arg(short, long, default_value = "./file.caddy")]
#[arg(short, long, default_value = "./file.conf")]
pub config: String,

/// Address for proxy server to listen on.
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! // Load configuration from file
//! let config = Config::from_file("config.caddy")?;
//! let config = Config::from_file("config.conf")?;
//!
//! // Create and start proxy
//! let proxy = Proxy::new(config);
Expand All @@ -38,7 +38,7 @@
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let config = Config::from_file("config.caddy")?;
//! let config = Config::from_file("config.conf")?;
//! let proxy = Proxy::new(config);
//!
//! // Spawn proxy in background
Expand All @@ -60,7 +60,7 @@
//! When built as a binary, the proxy can be run from command line:
//!
//! ```bash
//! tiny-proxy --config config.caddy --addr 127.0.0.1:8080
//! tiny-proxy --config config.conf --addr 127.0.0.1:8080
//! ```
//!
//! ## Configuration Format
Expand Down
10 changes: 5 additions & 5 deletions src/proxy/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::proxy::handler::proxy;
///
/// #[tokio::main]
/// async fn main() -> anyhow::Result<()> {
/// let config = Config::from_file("file.caddy")?;
/// let config = Config::from_file("file.conf")?;
/// let proxy = Proxy::new(config);
/// proxy.start("127.0.0.1:8080").await?;
/// Ok(())
Expand All @@ -48,7 +48,7 @@ use crate::proxy::handler::proxy;
///
/// #[tokio::main]
/// async fn main() -> anyhow::Result<()> {
/// let config = Config::from_file("config.caddy")?;
/// let config = Config::from_file("config.conf")?;
/// let proxy = Proxy::new(config);
///
/// // Get a handle to the shared config for hot-reload
Expand All @@ -62,7 +62,7 @@ use crate::proxy::handler::proxy;
/// });
///
/// // Later, update config at runtime
/// let new_config = Config::from_file("updated-config.caddy")?;
/// let new_config = Config::from_file("updated-config.conf")?;
/// {
/// let mut guard = config_handle.write().await;
/// *guard = new_config;
Expand Down Expand Up @@ -193,7 +193,7 @@ impl Proxy {
/// # use tiny_proxy::{Config, Proxy};
/// # #[tokio::main]
/// # async fn main() -> anyhow::Result<()> {
/// # let config = Config::from_file("config.caddy")?;
/// # let config = Config::from_file("config.conf")?;
/// # let proxy = Proxy::new(config);
/// proxy.start("127.0.0.1:8080").await?;
/// # Ok(())
Expand Down Expand Up @@ -270,7 +270,7 @@ impl Proxy {
/// # use tiny_proxy::{Config, Proxy};
/// # #[tokio::main]
/// # async fn main() -> anyhow::Result<()> {
/// # let config = Config::from_file("config.caddy")?;
/// # let config = Config::from_file("config.conf")?;
/// # let proxy = std::sync::Arc::new(Proxy::new(config));
/// proxy.start_all().await?;
/// # Ok(())
Expand Down
Loading