alias / root / proxy_pass 的区别

记录一下 nginx 配置里面 alias / root / proxy_pass 的区别

alias

别名配置, 匹配到的 url 路径会被替换

location /test {
	alias /img;
}

请求: /test/1.png
指向: /img/1.png

root

根路径配置, 匹配到的 url 会被拼接到 root 路径之后

location /test {
	root /img;
}

请求: /test/1.png
指向: /img/test/1.png

proxy_pass

反向代理, 匹配到的 url 会被转发到 proxy_pass 的 url

location /test {
	proxy_pass http://127.0.0.1:8082/img;
}

请求: /test/1.png
指向: http://127.0.0.1:8082/img/1.png


版权声明:本文为dog_m原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。