参考官网:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

定义:用来设置被代理服务器的协议(http或https)和地址(域名或者IP地址加端口),还可以设置可选的URI

例:proxy_pass http://localhost:8000/uri/

URI按如下规则传送给后端被代理服务器:

客户端请求以http://127.0.0.2:8080/test/xx/yy....为例被监听转发

1、如果proxy_pass使用了URI(就是有/),请求路径与loction路径的匹配部分将被 替换 为proxy_pass中定义的URI

location /test/{
  proxy_pass http://127.0.0.3/service/test1/;
}
转发以后的请求为http://127.0.0.3/service/test1/xx/yy...

2、如果proxy_pass没有使用URI,发给被代理服务器的请求路径和客户端发起的请求路径相同,不会被修改

location /test/ {
  proxy_pass http://127.0.0.3/service/test1;
}
转发以后的请求为http://127.0.0.3/service/test1/test/xx/yy...

特殊情况:

1、location 使用了正则表达式,这种情况下指令不应该带有URI。

2、使用rewrite指令改变了URI,并使用相同配置处理请求(break):

location /name/ {
rewrite /name/([^/]+) /users?name=$1 break;
proxy_pass http://127.0.0.1;
}

这种情况下,指令定义的URI将被忽略,改变后的URI将被发送给后端服务器。

最新文章

  1. mysql外键添加error1215
  2. java:同步和死锁
  3. 理解android.intent.action.MAIN 与 android.intent.category.LAUNCHER
  4. android 知识点收集
  5. github和bitbucket
  6. 【转】Web应用的组件化开发(二)
  7. LeetCode57 Insert Interval
  8. svn: E230001: Server SSL certificate verification failed
  9. Codeforces Round #115 B. Plane of Tanks: Pro 水题
  10. Android使用listView,BaseAdapter实现列表页
  11. ASP.NET Calendar 控件
  12. [置顶] Guava学习之Multimap
  13. 【Java】【Flume】Flume-NG源代码分析的启动过程(两)
  14. bzoj1877
  15. 2018-2019 20165220 网络对抗 Exp5 MSF基础
  16. 2018.02.12 noip模拟赛T2
  17. 写给spring版本的那些事儿
  18. Introduction to 3D Game Programming with DirectX 11 翻译--开篇
  19. Linux tomcat自动启动
  20. vs2013+python+ cocos2d-x-3.3rc0环境搭建

热门文章

  1. 泛微oa系统com.eweaver.base.DataAction文件sql参数sql注入
  2. Centos7使用Python3
  3. Django框架(二十八)—— Django缓存机制
  4. 快速调通支付宝当面付Demo
  5. Javascript中的相等比较
  6. JNI中修改(基本类型)参数并返回到Java层使用
  7. Android 5.1 预制输入法
  8. go垃圾回收
  9. [Luogu P4178]Tree 题解(点分治+平衡树)
  10. mysql笔试题大餐---1、组合查询方式及having