nginx location中uri的截取
发表于:2024-09-22 作者:千家信息网编辑
千家信息网最后更新 2024年09月22日,这篇文章给大家介绍nginx location中uri的截取,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。说明:location 中的 root 和 aliasroot 指令只是
千家信息网最后更新 2024年09月22日nginx location中uri的截取
这篇文章给大家介绍nginx location中uri的截取,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
说明:
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/lctest4location /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 worldroot@pts/1 $ curl http://tapi.xxxx.com/lctest2/hello world2root@pts/1 $ curl http://tapi.xxxx.com/lctest3/3hello worldroot@pts/1 $ curl http://tapi.xxxx.com/lctest4/hello world4
location alias
location /lctest5 { alias /data/web/;}location /lctest6/ { alias /data/web/;}location /lctest7 { alias /data/web;}## 403 /data/web forbiddenlocation /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/'403 Forbidden 403 Forbidden
nginx
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 urldone
测试结果
----------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
关于nginx location中uri的截取就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
结果
测试
内容
尾部
指令
更多
目录
路径
帮助
不行
不错
原始
兴趣
只是
备注
小伙
小伙伴
文件
文章
时候
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
中标数据库
网络安全实践活动有哪些
打造网络安全大脑
网络安全的主要技术有访问控制
网站阅读量数据库
米哈游账号注销提示网络安全风险
科洛斯数据库建立账号
怎么清理加密数据库
古籍单机数据库
数据库名与字段名不一致
昆明网络安全宣传周
sql大于10万条数据库
集团公司网络安全分为几级
ntp服务器配置文件
大型软件开发设计模式
北京直销软件开发帖子
华为电信招标服务器
青岛一帆网络技术有限公司
汕尾专业软件开发
晋城感严网络技术有限公司
虹口区信息网络技术收费标准
深圳直销软件开发公司宝安
十二鱼丸破坏服务器
网络安全需要我们的共同关注
西安软件开发品牌
物流中新的软件开发有什么
石器时代服务器怎么样
大麦打印服务器设置完怎么登
吉林省ipfs服务器云服务器
电力网络安全攻防