October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Nginx proxy_pass Trailing Slash: How the Upstream Path Is Chosen

A slash in proxy_pass and a slash-terminated location do different jobs. Here’s how to determine the upstream path and identify the key exceptions.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

proxy_pass changes the upstream path only when its value includes a URI: Nginx replaces the part of the normalized request URI that matches the location with that URI. Without a URI after the upstream address, Nginx follows a different pass-through rule. A slash at the end of a prefix location has a separate effect: a request for that exact path without the slash is redirected with HTTP 301.

What a URI in proxy_pass changes

The key distinction is whether the directive includes a URI after the upstream address. Nginx’s proxy module documentation defines the URI-bearing case this way: the part of the normalized request URI matching the location is replaced by the URI specified in proxy_pass.

As an Amazon Associate I earn from qualifying purchases.

location /name/ {
    proxy_pass http://127.0.0.1/remote/;
}

For a request to /name/item, the matching /name/ prefix is replaced with /remote/, yielding the upstream path /remote/item. The trailing slash in /remote/ is part of the replacement URI; it is not a general instruction to append or remove a slash from every request.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What happens when proxy_pass has no URI

If the directive ends at the upstream address, there is no replacement URI. For an original request, Nginx passes the request URI in its original form. If processing has changed the URI, Nginx passes the full normalized URI instead.

location /some/path/ {
    proxy_pass http://127.0.0.1;
}

In particular, omitting the URI does not mean “replace the matched location prefix with /.” It selects a different documented behavior. The distinction is between the upstream address alone and an address followed by a URI, even when that URI is just a slash.

Do not confuse the location slash rule with URI replacement

The core module documentation describes a separate special case for slash-terminated prefix locations. When a prefix location ends in a slash and uses a pass directive such as proxy_pass, a request whose URI exactly equals that location but lacks its final slash receives a permanent 301 redirect with the slash appended.

For example, with location /name/, a request for exactly /name is redirected to /name/. This concerns the incoming request and location handling. It is not the same operation as replacing a matched prefix with a URI in proxy_pass.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apply the rule to a configuration

To work out the upstream path, separate the incoming request, the matching location, and the value of proxy_pass. The simple replacement calculation applies when the directive includes a URI and the location is a prefix location in the ordinary case.

Rank #3
Forvencer Server Book, 2 Zipper Pocket, Server Books for Waitress
  • Upgraded Two Zipper Pockets: Forvencer server books feature two secure zipper pockets for better organization of coins, cash, and receipts, ensuring that everything you collect has a safe and secure place
  • Smart Storage & Quick Access: Designed with 8 multi-functional compartments, the right side includes a guest receipt pad, while the left has a money pocket, ticket pocket, and credit card slot. Two small clear pockets store bills, receipts, and other visible items. A stitched pen loop ensures you always have your favorite pen ready
  • High-quality & Easy to Clean: Crafted from high-quality PU leather with heavy-duty stitching, this server book is built to last. It resists tears, scratches, and its waterproof surface makes cleaning easy with just a damp cloth or a non-chlorine sanitizer
  • Perfect Fit for Your Apron: Measuring 5” x 8”, this compact organizer is slightly smaller than other models, making it ideal for bending or sitting while carrying in your server apron. It holds everything a waitress needs—a place for everything
  • What's Included: This server organizer comes with multiple open and zippered pockets to store money, receipts, tips, etc. Clear sleeves are perfect for keeping menus or special lists while serving. Available in a variety of colors, allowing you to express yourself even when in uniform
  1. Write the incoming path. For example, /name/item.
  2. Identify the matching location prefix. In location /name/, that prefix is /name/.
  3. Check whether proxy_pass includes a URI. http://127.0.0.1/remote/ includes /remote/; http://127.0.0.1 does not.
  4. If a URI is present, replace the matching prefix. Here, /name/ becomes /remote/, so the upstream path is /remote/item.
  5. If no URI is present, use the documented pass-through rule. Do not perform the prefix-replacement calculation.

This describes URI handling for normalized request URIs, not raw character-by-character editing of the original request target.

Exceptions that change the calculation

Regex and named locations

In regex and named locations, Nginx cannot determine the part of the URI to replace. The documentation says to specify proxy_pass without a URI in these cases.

A rewrite followed by break

If a rewrite changes the URI inside a proxied location and processing continues in that configuration using break, Nginx ignores the URI in proxy_pass and passes the full changed request URI upstream.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Variables in proxy_pass

Variable-based proxy_pass has different URI handling. If a URI is specified, it is passed as is and replaces the original request URI. Do not assume the ordinary location-prefix replacement example applies unchanged; evaluate the exact directive and its variables.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check documentation for your Nginx version

The linked Nginx documentation pages describe the behavior as checked on October 7, 2026. For release-specific details, consult the documentation corresponding to the Nginx version you run, especially if your configuration uses rewrites, variables, or regex or named locations.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.