Privoxy
Privoxy is a non-caching forward proxy: plain HTTP
requests are forwarded directly, HTTPS requests are tunnelled with CONNECT.
It never intercepts TLS, so pgcli manages no CA and no certificates — the
client’s own trust store keeps working. pgcli runs it as a standalone,
top-level addon with the usual lifecycle (install / start / stop / logs /
autostart / remove) managed through pg.yaml.
Typical uses:
- a shared egress proxy for hosts and containers that have no direct route (or need a single, auditable outbound address),
- a
HTTP_PROXY/HTTPS_PROXYendpoint for package managers,curl, and applications inside the fleet, - a network-level gate: only clients in
--allow-networkmay use it.
Platform support: Linux uses host networking; macOS uses the pgcli-net bridge with the port published. The image is multi-arch (amd64 + arm64).
How It Works
pgcli renders a complete Privoxy config from your flags and bind-mounts it
read-only at /etc/privoxy/config. Logs go to the container’s stdout
(logfile /dev/stdout), visible with pg logs addon privoxy. The image’s own
entrypoint is bypassed (--entrypoint /usr/sbin/privoxy) because it rewrites
the config file in place, which would fail on a read-only mount.
The rendered defaults are deliberately minimal and safe: caching is off,
remote toggles and CGI editing are disabled, request-blocking is not enforced,
and the proxy does not forward proxy authentication headers. No actions files
are loaded, so it is a pure forwarder — use --conf-file when you need
filtering.
Port assignment
Each instance gets its own port. The first one starts at
privoxy_start_port (default 8118); additional instances increment from
there, and any port already listening on the host (ss -tlnH) is skipped, so
installing several proxies on one machine never collides with each other or
with existing services:
Pin a port explicitly with --port N (a port already pinned to another
privoxy instance is rejected; a port owned by a non-pgcli process shows up as
a container start error).
Client ACLs
ACLs use Privoxy’s native syntax (host, addr[/mask][:port], and the
optional two-part form client-spec destination-spec). Two rules of Privoxy’s
own semantics matter:
- Once any
permit-access/deny-accessline exists, the default is deny. - The last matching line wins.
pgcli therefore renders permits before denies:
| Flags | Rendered result | Meaning |
|---|---|---|
--allow-network A,B |
permit-access A, permit-access B |
whitelist — everyone else is denied |
--deny-network C |
permit-access 0.0.0.0/0, deny-access C |
blacklist — everyone allowed except C |
--allow-network A --deny-network C |
permits first, then denies | allow a range, deny a narrower address inside it |
Both flags are repeatable and accept comma-separated lists; all forms are
merged (--allow-network 10.0.0.0/8,192.168.0.0/16 --allow-network 172.16.0.0/12
is one three-entry whitelist, and the same applies to --deny-network with
several addresses). Passing either flag replaces the stored list on
reinstall; passing neither clears it. With no ACL and a non-loopback listener
the install prints an open proxy warning — anyone who can reach the port
can proxy through it. Bind loopback (--listen 127.0.0.1) or add an ACL unless
the port is already firewalled.
For an IPv6 listener the catch-all permit is [::]/0 instead of 0.0.0.0/0.
Custom configuration
--conf-file FILE copies a full Privoxy config into the addon directory
instead of rendering one. It is mutually exclusive with the ACL flags; the
file owns listen-address (pgcli’s --port is then used only in the summary
and for macOS port publishing). Use this for upstream SOCKS forwarding, the
stock actions/filter files shipped in the image, or any directive the template
does not expose.
Because the file replaces the rendered config, it must be complete — nothing is inherited. A complete example that sends all traffic through a local SOCKS5 proxy and accepts only private-network clients:
Keep logfile /dev/stdout if you want pg logs addon privoxy to show request
logs. Only the config file itself is bind-mounted at /etc/privoxy/config;
directories and extra files are not mounted, so an actionsfile can only refer
to files already present in the image (the stock /etc/privoxy/*.action
set).
Commands
Re-running install re-renders the config and recreates the container only when
the rendered file changed (or when --force is set).
Using the proxy
For Ansible-managed fleets, set pgcli_proxy_url once in
group_vars/all/main.yml; see egress proxy.
A curl -v against an HTTPS URL shows CONNECT example.com:443 followed by a
normal TLS handshake with the origin — no certificate is replaced.
Autostart
At boot, pg start --autostart starts the container from the config already
on disk, recreating it if it was removed. Install the instance first.
Notes
- No TLS interception by design: no MITM CA, no certificate distribution. Clients validate the origin’s real certificate through the tunnel.
- No caching and no content filtering in template mode; add actions files
through
--conf-fileif you need filtering. - No authentication: Privoxy’s ACLs are address-based. Protect the port
with
--allow-network, a loopback bind, or a firewall. - The config directory is
<base_dir>/addon/privoxy/<name>/;removedeletes it, and there is no other state. - Default image:
ghcr.io/mars-base/pgcli/pgcli-privoxy:4.2.0(official amd64.deb, arm64 built from the official source tarball).