圆月山庄资源网 Design By www.vgjia.com
说明:
location 中的 root 和 alias
- root 指令只是将搜索的根设置为 root 设定的目录,即不会截断 uri,而是使用原始 uri 跳转该目录下查找文件
- aias 指令则会截断匹配的 uri,然后使用 alias 设定的路径加上剩余的 uri 作为子路径进行查找
location 中的 proxy_pass 的 uri
如果 proxy_pass 的 url 不带 uri
- 如果尾部是"/",则会截断匹配的uri
- 如果尾部不是"/",则不会截断匹配的uri
如果proxy_pass的url带uri,则会截断匹配的uri
Examples
location中的 root
root@pts/1 $ ls -ld /data/web/lctest*|awk '{print $NF}' /data/web/lctest /data/web/lctest2 /data/web/lctest3 /data/web/lctest4 location /lctest { root /data/web/; } location /lctest2/ { root /data/web/; } location /lctest3 { root /data/web; } location /lctest4/ { root /data/web; }
curl 测试结果如下
备注: 浏览器输入的时候最后面不添加 / , 会自动补上,但是curl 不行
root@pts/1 $ curl http://tapi.xxxx.com/lctest/ hello world root@pts/1 $ curl http://tapi.xxxx.com/lctest2/ hello world 2 root@pts/1 $ curl http://tapi.xxxx.com/lctest3/ 3 hello world root@pts/1 $ curl http://tapi.xxxx.com/lctest4/ hello world 4
location alias
location /lctest5 { alias /data/web/; } location /lctest6/ { alias /data/web/; } location /lctest7 { alias /data/web; } ## 403 /data/web forbidden location /lctest8/ { alias /data/web; }
curl 测试结果如下
curl 'http://tapi.kaishustory.com/lctest5/' curl 'http://tapi.kaishustory.com/lctest6/' curl 'http://tapi.kaishustory.com/lctest7/' 结果都是 /data/web/index.html的输出 root@pts/1 $ curl 'http://tapi.kaishustory.com/lctest8/' <html> <head><title>403 Forbidden</title></head> <body bgcolor="white"> <center><h1>403 Forbidden</h1></center> <hr><center>nginx</center> </body> </html>
location proxy_pass
#--------proxy_pass配置--------------------- location /t1/ { proxy_pass http://servers; } #正常,不截断 location /t2/ { proxy_pass http://servers/; } #正常,截断 location /t3 { proxy_pass http://servers; } #正常,不截断 location /t4 { proxy_pass http://servers/; } #正常,截断 location /t5/ { proxy_pass http://servers/test/; } #正常,截断 location /t6/ { proxy_pass http://servers/test; } #缺"/",截断 location /t7 { proxy_pass http://servers/test/; } #含"//",截断 location /t8 { proxy_pass http://servers/test; } #正常,截断
测试脚本
for i in $(seq 8) do url=http://tapi.xxxx.com/t$i/doc/index.html echo "-----------$url-----------" curl url done
测试结果
----------http://tapi.xxxx.com/t1/doc/index.html------------ /t1/doc/index.html ----------http://tapi.xxxx.com/t2/doc/index.html------------ /doc/index.html ----------http://tapi.xxxx.com/t3/doc/index.html------------ /t3/doc/index.html ----------http://tapi.xxxx.com/t4/doc/index.html------------ /doc/index.html ----------http://tapi.xxxx.com/t5/doc/index.html------------ /test/doc/index.html ----------http://tapi.xxxx.com/t6/doc/index.html------------ /testdoc/index.html ----------http://tapi.xxxx.com/t7/doc/index.html------------ /test//doc/index.html ----------http://tapi.xxxx.com/t8/doc/index.html------------ /test/doc/index.html
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com
暂无评论...
更新日志
2024年07月03日
2024年07月03日
- 原画壁纸及美图第264期,无水印可自取
- 绝区零感电鸣徽有哪些 绝区零感电鸣徽效果介绍
- 绝区零冻结鸣徽有哪些 绝区零冻结鸣徽效果介绍
- 绝区零丽娜角色精美壁纸分享 丽娜高清图片大全
- 《命运2:终焉之形》评测:在线人数几回峰值的史诗新篇
- 《艾尔登法环:黄金树幽影》评测:你所拥有的力量,正是你为王的理由
- 【游新视界】《幻兽帕鲁》帕桑!岛上滴樱花开了,不回来看看吗?
- 群星1996-《96滚石年度最卖座主打歌刷新全纪录·伤心咖啡馆之歌》台湾首版[WAV+CUE]
- 群星.1997-滚石年度最卖座专辑主打歌全纪录·乱世佳人2【滚石】【WAV+CUE】
- 群星1996-《96滚石年度最卖座主打歌刷新全纪录·新好男人2》台湾首版[WAV+CUE]
- Uzi谈停播原因:因锻炼身体太累所以休息了一下
- 纯欲身材经不住镜面反射 如何安慰失意男人的囧图
- Reddit网友称为了迎接《黑神话:悟空》的发售正在通读《西游记》
- 李翊君.1993-苦海女神龙【上华】【WAV+CUE】
- 群星.2009-重温意难忘5CD【新丽声】【WAV+CUE】