Nginx request_uri 和 uri 有何不同?

request_uri

request_uri: full original request URI (with arguments)

- 请求的整个生命周期里不会变化
- 携带原始参数的完整的uri

uri

uri: current URI in request, normalized
The value of $uri may change during request processing, e.g. when doing internal redirects, or when using index files.

- 不携带参数
- 值是可变的,比如发生内部重定向时, 通过$uri获取的值不一定是原始的请求路径, 因此当发生了内部重定向比如子请求时,要想保持原始的URI,需要使用$request_uri

如下:
location /media/ {
        internal;
        resolver 127.0.0.1 ipv6=off;
	default_type video/mp4;
	proxy_pass https://media.test.com$request_uri;
}
posted @ 2022-08-03 22:56  白--茶  阅读(620)  评论(0编辑  收藏  举报