root与alias
root会拼接location
alias不会拼接location
例如root
location /static{
root /home/nginx-1.11.2.4/html/pc/dist;
}
访问http://127.0.0.1:80/static/abc.pdf
寻找/home/nginx-1.11.2.4/html/pc/dist/static/abc.pdf
例如alias
location /static{
alias /home/nginx-1.11.2.4/html/pc/dist;
}
访问http://127.0.0.1:80/static/abc.pdf
寻找/home/nginx-1.11.2.4/html/pc/dist/abc.pdf
proxy_pass
proxy_pass以“/”结尾,不会拼接location后的路径
proxy_pass不以“/”结尾,会拼接location后的路径
例1
#访问地址:http://localhost:8081/model/asc.shtml
#最终代理:http://127.0.0.1:8082/model/asc.shtml
location /model/ {
proxy_pass http://127.0.0.1:8082/model/;
}
例2
#访问地址:http://localhost:8081/model/asc.shtml
#最终代理:http://127.0.0.1:8082/asc.shtml
location /model/ {
proxy_pass http://127.0.0.1:8082/;
}
例3
#访问地址:http://localhost:8081/model/asc.shtml
#最终代理:http://127.0.0.1:8082/AAAmodel/asc.shtml
location /model/ {
proxy_pass http://127.0.0.1:8082/AAA;
}
例4
#访问地址:http://localhost:8081/model/asc.shtml
#最终代理:http://127.0.0.1:8082/asc.shtml
location /model {
proxy_pass http://127.0.0.1:8082/;
}
标签:资源配置,0.1,127.0,http,shtml,静态,nginx,location,model From: https://www.cnblogs.com/sung1024/p/16976995.html