Prometheus behind a reverse proxy

Serving Prometheus and Alertmanager behind NGINX or another proxy means setting the external URL and route prefixes correctly, or the UI and API links break. This page covers the decisions, setup sequence and checks.

On this page

Why a Prometheus reverse proxy setup needs planning up front

Teams usually need a reverse proxy in front of Prometheus when the web UI and HTTP API must sit under a shared hostname or path, carry TLS on every connection, and sit behind the same sign-in as other internal tools. Prometheus does not provide these controls itself. Its security model states that it has no built-in single sign-on, and that it has no built-in CSRF protection on mutating endpoints. The usual answer is an authenticating reverse proxy such as NGINX in front of the web UI and API, which takes on TLS termination, path routing and authentication before a request reaches the Prometheus process. Alertmanager and any exporter UI that teams expose usually need the same treatment, so the decision covers more than one service.

The proxy does not stand alone once it is in place. Each part of it changes how Prometheus builds its own links and redirects. The --web.external-url flag tells Prometheus the address users reach it at, and --web.route-prefix controls the path it serves under. If these values do not match what the proxy forwards, the UI can load but its assets, redirects or API links point to the wrong address. Admin endpoints also deserve a decision here. The admin API is disabled by default, and --web.enable-lifecycle enables reload and shutdown endpoints, so the proxy rules should block or restrict those paths on purpose rather than by accident.

Before building anything, confirm three things with your security and platform teams: which identity provider will sit in front of the proxy, which hostnames and paths the monitoring estate will use, and who owns certificate issuance and renewal. Ask whether the proxy will also terminate TLS for scrape traffic or only for human access, because the two have different trust boundaries. Plan a test that confirms links, redirects and API calls work through the proxy, not only that the login page loads. Those checks are what make the setup reviewable later.

Which proxy pattern fits: subdomain, path prefix or internal only

Prometheus can be exposed on its own hostname, under a path on a shared host, kept inside the network, or placed behind a proxy that adds sign-in. Each choice changes how links resolve, who manages certificates and where access control lives, so decide it before writing the proxy configuration.

Dedicated hostname

Prometheus gets its own name, such as prometheus.example.internal, and the proxy forwards all paths to it. Links in the UI and API stay simple because the server sits at the root of the host, so the default external URL logic needs little change. Each hostname needs its own certificate or a wildcard certificate covering it. Check that your DNS, certificate renewal and proxy server blocks are managed as code, since every extra name adds another entry to maintain.

Security model

Path prefix under a shared host

Prometheus is served under a path such as /prometheus/ on a host that other tools already use. This saves a certificate and a DNS record, but every redirect, static asset and API link must agree with the prefix set through the external URL and route prefix options. Mismatches typically show up as broken UI assets or redirects to the wrong location. Test every page and the API path after each proxy change, and confirm the prefix is stripped or kept as the application expects.

Internal only, no proxy

Prometheus listens on a private address and is reached directly by engineers on the network, with no reverse proxy in front. This removes a component and keeps the TLS question limited to what Prometheus itself supports, which covers TLS and client certificates but not single sign-on. Access control then depends on network segmentation and firewall rules alone. Confirm who can reach the port, and that basic authentication is never used over plain HTTP.

Proxy that adds SSO

An authenticating proxy sits in front of the UI and API and requires users to sign in through your identity provider before requests reach Prometheus. Prometheus has no built-in single sign-on and no built-in CSRF protection on mutating endpoints, so this layer carries that control. Plan for it to cover the API path as well as the UI, and for service accounts used by Grafana or automation, which cannot complete an interactive sign-in. Ask your security team which identity provider and session policy will apply.

Keep admin endpoints closed

Whichever pattern you choose, the proxy should not expose administrative paths to every user. Admin HTTP APIs are disabled by default, and the lifecycle flag adds reload and shutdown endpoints. Block those paths at the proxy unless a specific automation needs them, and restrict them to a management network. Review the proxy rules whenever you add a path prefix, because a broad location block can expose endpoints that were meant to stay private.

Configuration options for web.external-url and route prefixes

This table compares the settings that decide how Prometheus and Alertmanager build their own links and accept requests behind a proxy, with the situations where each fits. Read each row against your proxy layout, then confirm the exact flag behavior in the documentation for the Prometheus and Alertmanager versions you run. The main takeaway is that the external URL, the route prefix and the proxy rewrite must describe the same public address, or links and API calls break in ways that look like application faults.

Setting or choiceWhen it fitsWhat breaks when it is wrong
web.external-url (Prometheus)Prometheus is served under a hostname or path that differs from its listen address, such as Use the full public URL including any path.Links in the UI, alert notifications and the Alertmanager sender point to the internal address, so operators click dead links and alerts carry unusable source URLs.
web.route-prefix (Prometheus)The proxy forwards a path prefix and does not strip it, so Prometheus must serve its routes under that same prefix. Confirm whether your version derives the prefix from the external URL.Static assets and API calls return 404 or the UI loads without data, because the browser requests paths the server does not register.
Proxy path rewrite (for example NGINX proxy_pass with or without a trailing slash)Use a rewrite when Prometheus should see root paths while users browse a subpath. Use no rewrite when Prometheus is configured for the prefix itself.A trailing slash mismatch strips or doubles the prefix, which causes redirect loops, broken CSS and JavaScript, or API paths that are off by one segment.
TLS termination at the proxyThe proxy holds the public certificate and talks to Prometheus over a trusted internal network. Common when the proxy also handles SSO or access control.Prometheus receives plain HTTP while the external URL says https, so generated links use the wrong scheme. Forwarded headers must be set and trusted correctly.
End-to-end TLS (proxy to Prometheus over TLS)The traffic crosses networks you do not fully control, or policy requires encryption between hops. Prometheus supports TLS with client certificates, with TLS 1.2 as the minimum.A certificate name or trust chain mismatch stops the proxy from reaching Prometheus, which appears as 502 errors. Keep the internal CA and expiry dates in your certificate inventory.
web.external-url (Alertmanager) and its route prefixAlertmanager runs under its own hostname or path. Set its external URL so notification links point to the public address. Confirm the matching prefix flag for your version.Notification links and the Alertmanager web UI point to the wrong address, and Prometheus alerting still works, so the fault often goes unnoticed until someone follows a link.
Prometheus alerting target configurationPrometheus sends alerts to Alertmanager at the address the proxy exposes or the internal address. Choose the path that matches your trust boundary and TLS design.If the address points at a load balancer rather than every Alertmanager instance, alerts can be lost or duplicated, and the Alertmanager documentation advises pointing Prometheus at each instance.

How a browser request reaches Prometheus through the proxy

The request starts in a user's browser and reaches the reverse proxy, which terminates TLS and can check identity before forwarding. The proxy then passes the path to Prometheus or Alertmanager, which must be configured with the same external URL and route prefix so that links generated by the UI and API resolve back through the proxy. The trust boundary sits between the proxy and the internal network, so check that the proxy is the only path in and that the backend listens only on internal addresses.

Requests pass through the proxy, which terminates TLS and forwards paths to internal services.

Setting up Prometheus and Alertmanager behind NGINX

This sequence puts Prometheus and Alertmanager under one public hostname and path, keeps their UI, API and alert links working, and closes the admin and lifecycle endpoints before users reach them.

  1. Decide the public URL and prefix

    Before editing any file, the platform owner and the network team agree on the public address for each service, for example one hostname with a path per tool or a separate hostname for each. Record the scheme, host, port and path prefix in the change ticket, and confirm the DNS record and the TLS certificate names with whoever manages them. Decide whether NGINX strips the prefix before forwarding or passes it through, because the answer determines the route prefix in step two. The step is done when the agreed URLs are written down and reviewed by someone who will not be the author.

  2. Set the external URL and route prefix

    Set the public address on Prometheus with the --web.external-url flag and, when the service sits under a path, the --web.route-prefix flag. Make the same decision for Alertmanager with its own external URL setting, so that links inside alert notifications point to the public address rather than an internal host. Keep the flags in the service definition or configuration file under version control, and do not rely on a shell session. Confirm the setting by restarting the service and checking that the process starts without errors in its logs. Verify the effective values against the startup output or the status page, which shows the configured external URL.

  3. Write the NGINX location and proxy headers

    Create one location block per service that forwards requests to the local listen address, and pass the original Host, X-Forwarded-Proto and X-Forwarded-For headers to the upstream. Make the location path match the route prefix exactly, including the trailing slash rules, because a mismatch is the most common cause of broken UI pages. Set a sensible proxy read timeout for long PromQL queries and keep the upstream on a private address that the public network cannot reach directly. Run the NGINX configuration test before reloading. The step is done when the configuration test passes and the reload completes without errors in the NGINX error log.

  4. Terminate TLS at the proxy

    Install the certificate and private key on NGINX, enable TLS for the public server block, and redirect plain HTTP to HTTPS. Prometheus supports TLS on its own listener, but when the proxy terminates TLS the upstream connection stays on a private network, and the team must decide whether that segment is acceptable under its own policy. Restrict protocol versions to those the security team has approved. Check the certificate chain from an external host with a TLS client and confirm the expiry date and subject names match the URLs from step one. The step is done when the handshake succeeds and the certificate matches the hostname.

  5. Restrict admin and lifecycle endpoints

    Admin HTTP APIs are disabled by default, so confirm that the --web.enable-admin-api flag is absent from the service definition unless there is a documented need. Review whether --web.enable-lifecycle is set, since it enables reload and shutdown endpoints that should not be reachable by ordinary users. If the lifecycle endpoint is needed for automation, block its path in NGINX for all public clients and allow it only from the automation host's address. Apply authentication to the remaining UI and API paths, either through an authenticating reverse proxy that handles single sign-on or through basic authentication over TLS. Confirm the result with curl from an outside host: the blocked paths should return a denial, and the UI should prompt for login.

  6. Verify the UI, API and static assets

    Open the public Prometheus URL in a browser and confirm the graph page, targets page and rules page load with their styling and scripts. Then run a query through the API using curl against the query endpoint under the public path, with credentials if authentication is enabled, and confirm a JSON response with a success status. Check the status and build information endpoints the same way. Missing stylesheets or scripts usually indicate a prefix mismatch, so compare the requested asset paths in the browser network panel with the NGINX location. The step is done when the UI renders completely and the API returns successful responses through the proxy.

  7. Verify Alertmanager and alert links

    Open the public Alertmanager URL and confirm that the status page, alert list and silences page load and that the configured external URL appears in its status output. Then check that links inside Prometheus alerts point to the public address: open an alert in the Prometheus alerts page and follow its source link, and confirm that it returns the graph page through the proxy. Trigger a test alert through a rule that is safe to fire in a non-production environment, and check that the notification template contains the public URL. Confirm that Prometheus lists every Alertmanager instance in its configuration. The step is done when the alert links open the correct pages from outside the internal network.

  8. Record the configuration and retest after changes

    Store the final NGINX configuration, service flags and the verification commands in the same repository as the rest of the monitoring configuration, so that a reviewer can rerun the checks later. Add the curl checks and the link checks to the runbook for upgrades and certificate renewals, because an upgrade can change paths or defaults. Ask the team that owns the upgrade calendar to confirm which release line is in use before testing a new version, and retest the full sequence after each change. The step is done when the checks are documented, the owner is named, and a retest is scheduled after the next upgrade or certificate renewal.

Security settings the proxy must enforce

Prometheus has few built-in access controls, so the reverse proxy in front of it carries much of the security load. The cards below list the settings the proxy should enforce, and each one maps to a specific part of the Prometheus security model that your team should verify in its own configuration.

TLS 1.2 minimum with client certificates

Prometheus supports TLS and client certificate authentication, with TLS 1.2 as the minimum version. Terminate TLS at the proxy with a version floor of TLS 1.2, and decide whether client certificates are required for human access, automation, or both. Check the negotiated protocol from outside the network, and confirm that no plaintext listener remains open on the same hostname or port.

Security model

Basic auth only over encrypted paths

Prometheus supports HTTP basic authentication with bcrypt-hashed passwords, but basic authentication without TLS sends credentials in cleartext. Configure the proxy so that basic auth is accepted only on HTTPS routes, and redirect or reject plain HTTP requests before they reach Prometheus. Review any internal health or scrape paths that clients might call over HTTP.

Admin and lifecycle endpoints blocked

Admin HTTP APIs are disabled by default, and the flags that enable them, such as --web.enable-admin-api and --web.enable-lifecycle, allow destructive operations and reloads or shutdowns. Keep these flags off unless a specific job needs them. If they are enabled, have the proxy deny /api/v1/admin/ and /-/quit and /-/reload to all users except a named automation identity on a restricted network path.

SSO enforced before the UI and API

Prometheus has no built-in single sign-on, and its security model notes there is no built-in CSRF protection on mutating endpoints. Place an authenticating reverse proxy or an SSO gateway in front of both the web UI and the API, so every request is authenticated before it reaches Prometheus. Confirm that direct access to the Prometheus port from other hosts is blocked, because a bypass around the proxy skips the SSO check.

Exporter endpoints kept private

Exporters such as SNMP and Blackbox take their targets from URL parameters, so anyone with HTTP access to them can make the exporter send requests to arbitrary endpoints. Do not publish exporter paths through the proxy. Restrict them to the Prometheus server's network address and require that only Prometheus scrape them, with the proxy rejecting any request from outside that source.

Questions teams ask before a Prometheus proxy setup

How much effort does a single-host Prometheus proxy setup take compared with a multi-team setup?

A single host with one proxy, one hostname and a few engineers is a small, contained change, while a multi-team setup takes longer because it adds more routes, more identity rules and more people who depend on the links working. The effort grows with the number of path prefixes, hostnames, TLS certificates and Alertmanager instances, and with how many dashboards, rules and integrations embed Prometheus URLs. Ask any partner to split the estimate into the proxy configuration, the testing of each link and the handover, and to state which of those scale with team count.

What does the internal team need to provide for a Prometheus proxy setup?

The internal team needs to own the decisions that the proxy depends on. That means the public hostname and any path prefix, the network path from the proxy to Prometheus and Alertmanager, the certificate authority or certificate process, and the identity provider if access will be controlled at the proxy. Someone also needs to know which Grafana data sources, alert receivers and scripts call the Prometheus API, because those callers break first when a prefix changes. Confirm these inputs before the work starts so the scope does not stall on access requests.

Can our own team set up a Prometheus reverse proxy without a partner?

Yes, many teams can do it with a Linux administrator who knows NGINX or another proxy and who has read the Prometheus configuration for external URLs and route prefixes. The harder parts are predictable: getting the external URL right so that UI links, redirects and API calls resolve, terminating TLS correctly, and checking that alerts and rule pages still work after a change. Teams without someone who has run this before often find the bugs in production. A partner is worth considering when the setup must be documented for an audit or when several teams depend on it.

What drives the cost of a Prometheus proxy setup?

Cost comes from the people doing the work and from the platforms they use. Prometheus itself is licensed under Apache-2.0 with no paid enterprise edition, so the spend is in the proxy platform, certificate issuance and renewal, identity integration if SSO is added, and testing of each route and link. One-time costs include design, configuration and the first round of verification. Recurring costs include certificate renewals, proxy upgrades and periodic retesting after Prometheus releases. Ask any quote to separate these items and to state who pays for each licence or certificate service.

Can the reverse proxy add single sign-on to Prometheus?

Yes, the usual pattern is an authenticating reverse proxy in front of the web UI and API, because Prometheus has no built-in single sign-on. The Prometheus security model notes that it has no built-in CSRF protection on mutating endpoints, which is another reason to put authentication in front of it. The proxy must still be configured so that API clients and automation can authenticate in a way they support, and admin endpoints such as those enabled by the admin API and lifecycle flags stay restricted. Confirm which identity provider and proxy module your team uses, and test SSO with a service account as well as with a person.

What changes when Alertmanager runs as a cluster behind the proxy?

Alertmanager clustering changes the routing, not just the URL. Alertmanager supports high availability through its cluster flags, and Prometheus should point at every Alertmanager instance rather than at a load balancer. That means the proxy must expose each Alertmanager address that Prometheus uses, or the internal address list must stay on a private network, and the external URL for the UI must still resolve to a working instance. Each Alertmanager needs its own route through the proxy if you expose it, and the team should test silences and notifications on each node after any change.

Limits to confirm in your environment

A proxy in front of Prometheus changes how paths, headers and cluster traffic behave, and the exact behavior depends on the version you run. The four checks below cover the items most likely to break after go-live, and each one should be confirmed against your own version and topology before the configuration is final.

Flag behavior for your version

Confirm how --web.external-url and the route prefix flag behave in the exact version you deploy, and whether it changes the links the UI and API generate. Check the release docs for that version, then compare with the current release line, since the supported minor and LTS lines change over time. Record the version you test against, because a proxy configuration that works on one release can produce broken links on another. Plan a retest on every upgrade.

Release cycle docs

Proxy header and path handling

Confirm how your proxy rewrites paths, forwards X-Forwarded-Prefix or similar headers, and handles trailing slashes, redirects and WebSocket or streaming responses used by the UI. Test the UI, the query API and the Alertmanager UI through the same proxy path, because a configuration that serves the homepage can still break API calls made by dashboards. Verify that the proxy does not strip the headers Prometheus needs to build correct absolute links.

SSO flow support in your product

Prometheus has no built-in single sign-on, so an authenticating proxy usually supplies it. Confirm that your identity product supports the redirect, token and session flow your proxy needs, and that it can pass the user identity to Prometheus without exposing credentials. Check how the flow handles API clients, service accounts and automated scrapes, which often cannot complete an interactive login. Plan explicit bypass rules for those paths.

Prometheus security model

Alertmanager peer reachability

Alertmanager cluster peers talk to each other on their cluster address and port, and Prometheus must reach every instance directly rather than through a load balancer. Confirm that the cluster traffic does not pass through the reverse proxy at all, and that each peer can resolve and reach the others on the internal network. Verify that the advertised addresses are correct when the instances sit behind NAT or a proxy hostname, or the cluster will not form.

How DeployOpen scopes and delivers a Prometheus proxy setup

DeployOpen starts a Prometheus proxy engagement with a written scope that names the hostnames or path prefixes, the reverse proxy in use (NGINX or another proxy), the Prometheus and Alertmanager instances being served, and where TLS terminates. Most engagements of this kind are fixed-scope, so the deliverables and timelines are agreed in writing before any configuration changes are made. The scope also records which authentication layer sits in front of the UI and API, because Prometheus has no built-in single sign-on and the security model expects an authenticating proxy for that role. Ask for this document to list each URL the team must be able to reach, and each item that is out of scope, such as changes to upstream DNS or certificate authority workflows.

Delivery happens inside your infrastructure, on your servers, proxies and certificate tooling. DeployOpen sets --web.external-url so that generated links in the UI and alert notifications match the public address, configures route prefixes on Prometheus and Alertmanager to match the proxy path, and aligns the proxy's forwarded headers and redirects with those settings. Testing covers the UI, the HTTP API endpoints that Grafana and other clients call, the Alertmanager UI and webhook links, and the links that appear inside alert messages. Confirm with the team whether the admin and lifecycle endpoints remain disabled behind the proxy, since the security model keeps them off by default and exposing them through a path prefix is a common mistake. Retesting after any proxy or Prometheus upgrade is a separate line item to agree in the scope.

Ongoing work after handover, such as proxy configuration changes, Prometheus version upgrades, certificate renewal support and periodic link and API checks, can be covered by a retainer. Ask any provider, DeployOpen included, to separate one-time setup from recurring support in the quote, and to state who owns the proxy, the certificates and the on-call response. DeployOpen is a Chainscore Labs company. It does not issue certifications for the resulting setup; the scope should say that any compliance evidence is prepared for your assessor rather than attested by DeployOpen.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.