# Named location

**URL:** <https://community.nginx.org/t/named-location/9795>\
**Category:** NGINX\
**Tags:** reverse-proxy\
**Created:** [June 20, 2026, 10:45pm UTC](https://community.nginx.org/t/named-location/9795 "2026-06-20T22:45:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xlf](https://avatars.discourse-cdn.com/v4/letter/x/e5b9ba/32.png) [@xlf](https://community.nginx.org/u/xlf)\
**Post date:** [June 20, 2026, 10:45pm UTC](https://community.nginx.org/t/named-location/9795/1 "2026-06-20T22:45:34Z")

</div>

What’s the difference between named location and an ordinary location with `internal`?

Where are named locations allowed? `auth_request` doesn’t need to be external but if I try `auth_request @auths` with a named location it doesn’t work. The error log has `open() "/etc/nginx/html@auths" failed (2: No such file or directory)` and `subrequest: "@auths"`.

---

<div class="post-metadata">

**Author:** ![bit\_warrior](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/bit_warrior/32/257_2.png) [@bit\_warrior](https://community.nginx.org/u/bit_warrior)\
**Post date:** [June 22, 2026, 3:04pm UTC](https://community.nginx.org/t/named-location/9795/2 "2026-06-22T15:04:15Z")

</div>

You’ve hit on a classic Nginx “gotcha.” The core issue is that **named locations (**`@`**)** and **regular locations** are handled fundamentally differently, and the standard `auth_request` module **does not support** named locations.

**Regular Location :** location /path { … }  
**Named Location (**`@`**) :** location @name { … }

A regular location is a “door” for external traffic. A named location (`@`) is a purely internal “shortcut” that bypasses standard URI matching.  
Named locations **cannot** be accessed directly by a browser or external client. They are strictly reserved for **internal directives** that perform an internal jump.  
They only work with :  
`error_page` – e.g., `error_page 404 @fallback; `  
`try_files` – e.g., `try_files $uri @fallback;`  
`return` (for internal redirects, though with limitations).

You receive error because the in standard NGINX, the `auth_request` directive **does not accept named locations.** Since you cannot use a named location, use a **regular location marked as** `internal`. This gives you the exact same security benefit (blocking external access) while remaining fully compatible with `auth_request`.

**Example Fix:**

```auto
location /private/ {
# Call the internal authentication subrequest
auth_request /auth;
# ... your proxy_pass or root config here
}

location = /auth {
# Crucial: prevents external users from hitting this endpoint directly
internal;

# Proxy to your authentication service
proxy_pass http://your_auth_service;

# Recommended: strip the request body for auth checks
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
# ... other proxy headers

}

```

---

<div class="post-metadata">

**Author:** ![system](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/system/32/19_2.png) [@system](https://community.nginx.org/u/system)\
**Post date:** [July 22, 2026, 3:04pm UTC](https://community.nginx.org/t/named-location/9795/3 "2026-07-22T15:04:27Z")

</div>

Closed on July 22, 2026, 3:04pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
