Web proxy chaining
How a Bytesafe proxy sits behind your company's web proxy, why the web proxy trusts a Bytesafe certificate, and how requests are routed to firewalls and attributed.
A company web proxy, such as Zscaler, Prisma Access, or Squid, already sits between developers and the internet and already decrypts their TLS traffic. A Bytesafe proxy is a destination that web proxy can hand registry traffic to. The web proxy decides which hosts go there; Bytesafe decides which firewall checks each request.
Package managers can keep their registry settings. Requests that reach the company proxy and match its forwarding rules go through the attached firewall. For setup, see Connect a web proxy.
Two TLS connections
A request crosses two encrypted connections. The package manager talks TLS to the web proxy, which presents a certificate from the company's own CA, already trusted on developer machines. The web proxy then talks TLS to Bytesafe, asking for the same registry host.
On that second connection the web proxy expects a certificate for registry.npmjs.org, not for a Bytesafe hostname. Bytesafe cannot present the registry's real certificate, so it presents one signed by a CA the web proxy trusts. That is the only reason a proxy has a CA: it proves the Bytesafe end of the chain to your web proxy. Developer machines never see it.
Routing to firewalls
Each proxy has firewalls attached. Every host those firewalls cover is routed to the firewall that covers it:
- the ecosystem's public registry, such as
registry.npmjs.orgorpypi.org - hosts the ecosystem's stock package managers use besides it:
registry.yarnpkg.comfor npm,index.rubygems.orgfor RubyGems - the host of each upstream, including inherited ones, so a firewall in front of an internal registry routes that host too
If two attached firewalls cover the same host, Bytesafe routes it to neither. Attaching both is refused. If a later upstream change creates the overlap, the host stays unrouted until you remove it. Requests for hosts the proxy does not route are refused.
A routed request goes through the firewall's normal routes. Package metadata the firewall returns points downloads at the Bytesafe API host, which is why the web proxy forwards that host too. For npm, a lockfile whose tarball URLs point at registry.npmjs.org also works: those paths are translated to the firewall's download route.
Which CA answers
A web proxy either opens a tunnel with CONNECT and then talks TLS inside it, or talks TLS to Bytesafe directly as if Bytesafe were the registry. Either way, Bytesafe answers the TLS handshake before any request arrives, so it can only use what it knows at that moment.
- This proxy's own CA isolates the proxy: its key signs certificates for nothing else. The web proxy has to send the credential as
Proxy-Authorizationwhen it opens the tunnel, so Bytesafe knows the proxy in time. - Shared Bytesafe root is one root for every proxy in the deployment. Bytesafe can answer any handshake with it, so the credential can arrive later, in the
X-Bytesafe-Proxy-Tokenheader on each request. A web proxy that already trusts the root needs nothing new for a second proxy.
A self-hosted endpoint can also name one default proxy, which answers every handshake that arrives without a credential. That covers a single web proxy without a shared root.
The shared root signs through an issuing CA below it, so the issuing key can be replaced without anyone installing a new root.
Choosing the certificate
The choice follows from how your web proxy can send the credential:
| Your web proxy | Certificate |
|---|---|
Opens a tunnel and can send Proxy-Authorization | Either. This proxy's own CA keeps the proxy isolated |
| Can only add a header to each request | Shared Bytesafe root |
| Connects to Bytesafe over TLS without a tunnel | Shared Bytesafe root |
The dashboard offers the choice only when the deployment has a shared root. Without one, every proxy uses its own CA.
Credential and attribution
A proxy's credential (prx-...) can fetch packages only through the proxy's attached firewalls, and a proxy with no firewalls does not authenticate at all. Rotating it replaces it at once.
Because the proxy makes the requests, log entries record the proxy instead of a user. A web proxy can report who it authenticated in a header such as X-Authenticated-User. When the proxy is set to trust that header, the value is recorded as proxyUser. It is the web proxy's claim and grants nothing: it does not affect permissions or rule evaluation. Field details: Logs reference.
Related
- How-to: Connect a web proxy, Enforce firewall use
- Reference: Proxies, Logs
- Concept: Upstreams and caching, Deployment models