nginx的location的root/alias/pass_proxy的区别

以http://127.0.0.1/static/img/index.html为例

1.

location ^~ / static / { 

         alias /usr/local/;

}

/usr/local/img/index.html

alias会把url里/static/之前包括/static/替换成/usr/local/去文件里找

2.

location ^~ / static / { 

         root /usr/local/;

}

/usr/local/ static /img/index.html

root会把url里/static/之前替换成/usr/local/去文件里找

 

3.

location ^~ / static / { 

         proxy_pass http://127.0.0.1:8080;

}

127.0.0.1:8080/static/img/index.html

proxy_pass会替换掉/static/之前的进行转发

发布了514 篇原创文章 · 获赞 182 · 访问量 36万+

猜你喜欢

转载自blog.csdn.net/dmw412724/article/details/103261094
今日推荐