找不到包含 uri 路径部分的 nginx 变量

Can't find nginx variable that contains the path portion of the uri

我在 NGINX 中使用重写指令添加尾部斜杠。目前我是这样做的:

# 301 Redirect for trailing slash
location ~ ^([^.]*[^/])$ {
    try_files $request_uri @addslash;
}

# 301 Redirect for trailing slash
location @addslash {
    return 301 $uri/$is_args$args;
}

它有效,但仅在端口 80 上有效。现在我正在寻找一种方法来重写此构造的第二部分以转发到正确的端口。

我找到了. But it doesn't forward the rest of the uri as it is. The part that comes after the port is not considered. For my construct, that would be the "path" portion of the uri

哪个nginx变量只包含路径部分?或者 uri 中端口之后的所有内容?

并且:有人知道带有示例的 nginx 变量列表吗? The one from the documentation 在这种情况下并没有真正的帮助:-P

好的,对于这个特定的问题,我找到了答案:

# 301 Redirect for trailing slash
location ~ ^([^.]*[^/])$ {
    try_files $request_uri @addslash;
}

# 301 Redirect for trailing slash
location @addslash {
    return 301 $scheme://$http_host$request_uri/$is_args$args;
}

$request_uri 是我要找的变量。原来我离得很近。

如果有一个带有示例的 nginx 变量列表仍然很好,因为 nginx 似乎使用与 uri 规范不同的措辞。