nginx之location

来源:互联网 发布:orange软件下载 编辑:程序博客网 时间:2024/06/05 14:14

nginx中location使用方法


1、跳转其他服务器

可以使用proxy_pass :添加其他服务器的访问ip信息


2、跳转nginx中应用

1)root

location  /mall/ {

    root /www/doc/;

}

这样访问  ip/mall/a.html --> (跳转到)ip/www/doc/mall/a.html

可见是把  ip 后面添加root后路径 然后添加locatioin后面的路径,添加location路径后面的a.html, 查找到对应的页面。

可以搭配index

location  /mall {

    root /www/doc/;

    index b.html

}

这样访问: ip/mall-->(跳转到)ip/www/doc/mall/b.html

2)alias

alias 和root在访问路径拼接上稍有不同

location  /mall/ {

    root /www/doc/;

}

这样访问  ip/mall/a.html --> (跳转到)ip/www/doc/a.html

可见是把  ip 后面添加root后路径 然后舍弃locatioin后面的路径,添加location路径后面的a.html,查找到对应的页面。

可以搭配index

location  /mall {

    root /www/doc/;

    index b.html

}

这样访问: ip/mall-->(跳转到)ip/www/doc/b.html


注:如果不允许方法某个路径下的资源可以添加   deny all;  参数。


参考连接:http://www.iigrowing.cn/shi-yan-que-ren-nginx-root-alias-location-zhi-ling-shi-yong-fang-fa.html

                  http://blog.csdn.net/u011510825/article/details/50531864



0 0
原创粉丝点击