Skip to content

Instantly share code, notes, and snippets.

@inso
Forked from ilguzin/nginx_redirect_2named_location
Last active February 27, 2024 17:46
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save inso/66135b102a3fe2f8d47f to your computer and use it in GitHub Desktop.
Save inso/66135b102a3fe2f8d47f to your computer and use it in GitHub Desktop.
NGINX: Redirect from current location into named location
# Solution 1
# Use only codes greater than 418, do not use common status codes 404, 402, 403, etc
location /location1 {
error_page 463 = @app; return 463;
}
# Solution 2 (drawbacks unknown)
location /location2 {
try_files /dev/null @app;
}
location @app {
proxy_pass http://127.0.0.1:82;
proxy_redirect off;
include proxy_params;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment