Skip to the content.

Bazel (Bzlmod)

Use the proxy as the module registry. The examples use the upstream name bazel; replace it with the name your operator gave the upstream (what you need).

   
Upstream type bazel
Package source https://proxy.example.com/v1/bazel
Clients bazel (6 and later, with Bzlmod)
Tested Bazel 7.4: in CI on every push and in the client lab.

Configure

In the workspace’s .bazelrc (or ~/.bazelrc):

common --registry=https://proxy.example.com/v1/bazel

A module’s source archive — usually a release on GitHub — comes through the proxy as well: the proxy rewrites each module’s source.json to point at itself, and verifies the archive against the registry’s integrity hash.

Authenticate

Only when the proxy has access control switched on. The proxy takes your proxy token as the password of HTTP Basic authentication, with any user name. Bazel reads credentials for a host from ~/.netrc (mode 600):

machine proxy.example.com
  login pullthrough
  password <token>

Trust a private CA

Bazel’s server is a JVM with its own trust store, and it does not read PEM bundles. Copy the trust store of a JDK — it holds the public CAs, which Bazel still needs for what it downloads directly — and add the CA to the copy:

cp "$JAVA_HOME/lib/security/cacerts" /etc/ssl/corp-truststore.jks
keytool -importcert -noprompt -trustcacerts -alias corp-ca -file /etc/ssl/corp-ca.pem \
    -keystore /etc/ssl/corp-truststore.jks -storepass changeit

(keytool on a file that does not exist creates a store with the corporate CA alone.)

and hand it to the server in .bazelrc:

startup --host_jvm_args=-Djavax.net.ssl.trustStore=/etc/ssl/corp-truststore.jks --host_jvm_args=-Djavax.net.ssl.trustStorePassword=changeit

Without it, every registry request fails with PKIX path building failed.

Check that it works

bazel fetch --repo="@platforms"

bazel mod graph resolves the whole module graph through the registry.

Good to know

On the proxy

upstreams:
  bazel:
    type: bazel
    url: https://bcr.bazel.build

Registry files are served live; source.json is rewritten so the source archive is fetched through the proxy (which is why server.publicUrl must be set), verified against its integrity hash and cached immutably. Details: backends: bazel.