The Simplest Way to Make Gerrit and Nginx Work Like They Should
Running gerrit and nginx together puts a fast web server in front of your code review app. Nginx handles incoming web traffic and TLS, while Gerrit manages Git repos and code reviews. This setup keeps your review server safe from direct public traffic. Your team gets fast page loads and clean URLs for every code change. It also lets you run multiple web services on the same host machine. How traffic and logins flow between gerrit and nginx Gerrit includes a built-in web server that listens o
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Running gerrit and nginx together puts a fast web server in front of your code review app. Nginx handles incoming web traffic and TLS, while Gerrit manages Git repos and code reviews.
This setup keeps your review server safe from direct public traffic. Your team gets fast page loads and clean URLs for every code change. It also lets you run multiple web services on the same host machine.
How traffic and logins flow between gerrit and nginx
Gerrit includes a built-in web server that listens on a local port. Nginx sits at the network edge and takes all incoming web requests first. When a developer opens a review page, Nginx checks the TLS certificate first.
Nginx then forwards the clean request to the local Gerrit port. You can also let Nginx handle user logins before traffic reaches Gerrit. In this mode, Nginx checks the user identity against an external directory service.
Once the check passes, Nginx sets a trusted header with the user name. Gerrit reads that header and logs the user into the right account. From there, Gerrit applies its own project rules and branch permissions.
Git over HTTP traffic follows the exact same path through the web server. SSH traffic for Git commands usually goes straight to the Gerrit SSH port. Some teams also route SSH through a separate stream block in Nginx.
Common failure modes and how to fix them
Many teams run into broken redirects when they first link these two tools. This happens when the base URL in Gerrit does not match the Nginx address. You must set the exact same public URL in both places.
Encoded slashes in change URLs also cause frequent errors for developers. Gerrit uses encoded characters in its REST API paths to identify project names. If Nginx decodes those slashes, Gerrit will reject the request with a not found error.
End-to-End Encryption + NGINX Security Configuration: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
To fix this, tell Nginx to pass the raw request URI without changes. Another big risk comes from leaving the local Gerrit port open to the whole network. If anyone can reach Gerrit directly, they can fake the login header.
Always bind the Gerrit web listener to the local loopback address only. That way, only the local Nginx process can send web traffic to Gerrit. You should also avoid shared admin accounts for build bots and scripts.
Give each bot its own account with the smallest role it needs. Scope those roles to specific Git branches and review labels. Turn on request logs in both tools so you can trace every action.
Keeping daily operations simple for your team
Large Git pushes over HTTP can fail if Nginx blocks big request bodies. Check your max body size limits in Nginx so large commits go through. You should also tune read timeouts so slow clones do not drop midway.
Keep your TLS keys safe on the host disk with strict file rules. Only the root user or the web server process should read those keys. Test your setup in a staging space before you change live settings.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Why does Gerrit return a 400 or 404 error on project URLs?
Nginx often changes encoded slashes in URLs before sending them to the backend. Configure Nginx to pass the original, unmodified request URI directly to the Gerrit port.
Should Nginx handle SSH traffic for Gerrit too?
Most teams only use Nginx for HTTP and HTTPS traffic. Gerrit has its own built-in SSH server that handles Git clones and pushes on a separate port.
How do we stop users from faking login headers?
Bind Gerrit to localhost so outside networks cannot reach its HTTP port directly. Also tell Nginx to strip any incoming login headers from external client requests first.
Related guides
In this post