Skip to content
awesomo4000Public

About

proxy pass through

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

34 Commits

Folders and files

Repository files navigation

proxzy

HTTP proxy that accepts plain HTTP and forwards to HTTPS upstream servers.

Build

Requires Zig 0.15+:

zig build

Usage

./zig-out/bin/proxzy --upstream=https://api.example.com --port=8080

Options

Option Default Description
--port=PORT 8080 Listen port
--upstream=URL https://httpbin.org Upstream server URL
--log-requests on Log incoming requests
--no-log-requests Disable request logging
--log-responses on Log responses
--no-log-responses Disable response logging
-v, --verbose off Verbose output (headers, body preview)
-h, --help Show help

Example

# Start proxy
./zig-out/bin/proxzy --upstream=https://httpbin.org --port=8080

# In another terminal, test it
curl http://localhost:8080/get

Library Usage

proxzy can be used as a Zig library dependency with custom middleware:

const proxzy = @import("proxzy");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    const allocator = gpa.allocator();

    var proxy = try proxzy.Proxy.init(allocator, .{
        .port = 8080,
        .upstream_url = "https://api.example.com",
        .middleware_factory = MyMiddleware.create,  // Optional
    });
    defer proxy.deinit();

    try proxy.listen();
}

Examples

Build and run the middleware examples:

# Build examples
zig build examples

# Run simple middleware (adds X-Proxzy-Id header)
./zig-out/bin/proxzy-transform-simple

# Run roundtrip middleware (modifies request body, restores on response)
./zig-out/bin/proxzy-transform-roundtrip

See examples/ for full source code.

Tests

# Run unit tests
zig build test

# Run integration tests
./tests/run_all.sh

Architecture

Client ──HTTP──► proxzy ──HTTPS──► Upstream
       ◄─HTTP──        ◄──HTTPS──
  • Server: httpz library (multi-threaded)
  • Client: libcurl + mbedTLS (vendored)
  • Thread safety: Per-request arena allocators

See docs/streaming-and-transforms.md for SSE streaming support.

About

proxy pass through

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages