Skip to content

iam4x/zig-http-proxy-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zig-http-proxy-docker

Small Zig HTTPS forward proxy for Bun fetch() running in Docker.

Scope

  • Supports HTTPS targets via HTTP CONNECT
  • Requires Proxy-Authorization: Basic ...
  • Exposes a plain HTTP proxy endpoint such as http://user:password@127.0.0.1:8080
  • Intentionally does not support plain HTTP target URLs in v1

Build

docker build -t zig-http-proxy .

Run

docker run --rm \
  -p 8080:8080 \
  -e PROXY_USERNAME=user \
  -e PROXY_PASSWORD=password \
  zig-http-proxy

Optional environment variables:

  • PROXY_BIND_HOST default 0.0.0.0
  • PROXY_PORT default 8080
  • PROXY_CONNECT_TIMEOUT_MS default 10000
  • PROXY_IO_BUFFER_SIZE default 16384
  • PROXY_MAX_HEADER_BYTES default 32768

Bun example

const res = await fetch("https://foobar.com", {
  proxy: "http://user:password@127.0.0.1:8080",
});

console.log(res.status);

Verify with curl

Successful HTTPS request through the proxy:

curl -x http://user:password@127.0.0.1:8080 https://example.com -I

Expected authentication failure:

curl -x http://127.0.0.1:8080 https://example.com -I

Expected unsupported plain HTTP target:

curl -x http://user:password@127.0.0.1:8080 http://example.com -I

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages