How to Set Up Custom Locations in Nginx Proxy Manager

Custom locations in Nginx Proxy Manager (NPM) let one domain send different URL paths to different services, like example.com/grafana/ to Grafana and example.com/files/ to a file server. To add one, edit a proxy host, open the Custom locations tab, click Add location, enter the path in Define location, then fill in the Scheme, Forward Hostname / IP, and Forward Port for the service and click Save. The part that trips most people up is trailing slashes, which control whether the path gets passed along to the app. That’s explained below.

Before you start

  • You need a working proxy host in NPM for the domain, like example.com. Custom locations are added to an existing host.
  • Know the IP address and port of each service, such as 192.168.1.20:3000.
  • Check whether each app can run under a sub-path. Many apps have a setting called base URL, URL base, or root URL. Apps without one often break when served from a sub-path, and a subdomain is the better choice.

How to add a custom location

  1. Sign in to the NPM admin panel, usually at http://your-server-ip:81.
  2. Go to Hosts > Proxy Hosts.
  3. Click the three-dot menu next to your host and choose Edit.
  4. Open the Custom locations tab and click Add location.
  5. In Define location, type the path, such as /grafana/.
  6. Choose the Scheme (http or https) that the service itself uses.
  7. Enter the service’s Forward Hostname / IP and Forward Port.
  8. Click Save, then visit https://example.com/grafana/ to test it.
Nginx Proxy Manager Edit Proxy Host window with the Custom locations tab and Add location fields highlighted
(1) Open Custom locations, then (2) enter the scheme, host, and port for the path. (Illustration)

The proxy host’s main Details tab still handles everything that doesn’t match a custom location, such as example.com/.

Trailing slashes: keep or strip the path

NPM builds an Nginx location block from your fields. Nginx follows one rule: if the forward address ends with a path (even just /), Nginx replaces the matched location with that path. If it doesn’t, the full original path is passed through.

Define location Forward Hostname / IP A request for /grafana/login goes to
/grafana/ 192.168.1.20 http://192.168.1.20:3000/grafana/login
/grafana/ 192.168.1.20/ http://192.168.1.20:3000/login
/grafana 192.168.1.20/ http://192.168.1.20:3000//login (double slash, avoid)
  • Keep the path (first row) when the app is set up with a matching base URL, like Grafana’s root_url set to https://example.com/grafana/ with serve_from_sub_path turned on.
  • Strip the path (second row) when the app expects to be at the root. Links inside the app may still point to the root, though, so this only works well for simple apps and APIs.
  • Always end both the location and the forward path with a slash, or leave both off, to avoid double or missing slashes.

Adding custom Nginx settings to a location

Click the gear icon on a location to open a text box for extra Nginx directives. A common use is WebSockets, which many dashboards and terminals need:

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

If what you enter doesn’t seem to apply, NPM’s generated file may not be combining it the way you expect. Check the config for your host inside the container at /data/nginx/proxy_host/, numbered by host ID. For complex rules, you can put a complete location block in the host’s Advanced tab instead.

Common problems and fixes

  • The page loads but has no styling, or shows a blank screen. The app is loading CSS and scripts from the root instead of the sub-path. Set the app’s base URL setting, or use a subdomain.
  • 502 Bad Gateway. NPM can’t reach the service. Check the IP, port, and scheme, and make sure the container or server is running. See fixing Bad Gateway errors in Nginx Proxy Manager.
  • 404 Not Found. The path is probably being passed through or stripped when the app expects the opposite. Try adding or removing the trailing slash on the forward hostname.
  • Redirects go to the wrong place. The app is redirecting to its internal address. Set its external or base URL to the public address.
  • Real-time features don’t work. Turn on Websockets Support on the Details tab and add the WebSocket headers shown above.

Custom location or subdomain?

Subdomains, like grafana.example.com, work with almost every app without extra setup, and each gets its own SSL certificate and access list in NPM. Custom locations are handy when you only have one domain or certificate, or for APIs and apps that support a base URL. If an app fights you on a sub-path, switching to a subdomain is usually the fastest fix. To limit who can reach a path or host, see how to set up an access list in Nginx Proxy Manager.

Before adding locations, finish the first admin setup on port 81.

Frequently asked questions

Can custom locations point to different servers?

Yes. Each location has its own hostname and port, so one domain can route to services on different machines.

Do custom locations use the host’s SSL certificate?

Yes. The certificate on the proxy host’s SSL tab covers every path on that domain.

Can I use regular expressions in Define location?

The field is meant for simple paths. For regex matching, write a full location ~ … block in the Advanced tab.

What’s the default Nginx Proxy Manager login?

New installs have used [email protected] and changeme, and newer versions may ask you to create an account on first launch. See setting up the default login for Nginx Proxy Manager.