假设 fileserver的位置是192.168.101.65:9000
upstream fileserver{
server 192.168.101.65:9000 weight=10;
}
第一种类型 : /video 代理类型
location /video {
proxy_pass http://fileserver;
}
如果是单斜杠,那么假设访问 /video/test.mp4
实际会被替换成 http://192.168.101.65:9000/video/test.mp4
第二种类型: /video/代理类型
location /video/ {
proxy_pass http://fileserver/;
}
访问/video/test.mp4
实际上是替换成 http://192.168.101.65:9000/test.mp4
两者是有区别的,这也是我开发过程中遇到过的一个坑。