nginx,rewrite,proxy_pass,post数据,表单
来源:互联网 发布:java面向对象 编程题 编辑:程序博客网 时间:2024/05/18 03:37
今天接到一个需求,前台要调用后台的短信发送网关:必须以post形式传递参数,并且前台的发送短信的请求的url和后台的发送短信的url不一致
前台的url为http://xxx.test.com/ajax/mobiledynamiclogincode
后台的发送短信网关的url为:
http://xxx2.test.com/json/account/mobiledynamiclogincode
分析:
1、nginx中的rewrite到外部url会导致post的参数丢失,所以放弃该方案。(内部的rewrit是不会丢失post数据)
原因:
(1)post的时候,参数是存放在message body中传递的,对于内部的url调转,因为是相同的一次请求,所以message body(request body)没变,所以post数据不会丢失。
(2)而对于外部跳转,实际上是一次302,即用户在请求了一次,所以第二次就不会post第一次的数据了。
具体如下:你post数据之后,匹配到rewrite之后,因为是外部的url,用户会看到一个302,之后请求的url就变成了get。。那么之前post的数据就丢失了(因为用户没有再提交一次数据)
2、需要传递post参数,需要使用proxy_pass。同时,因为proxy之前的url和proxy的url不同,需要做location,并需要在在proxy_pass中写全路径参考例子如下
思考了为啥proxy_pass能传递post的参数:因为对于用户而言,就只是一个请求,所以request body没变。nginx会将该request body传递到后续的server
location /ajax/mobiledynamiclogincode {
proxy_pass http://xxx2.test.com/json/account/mobiledynamiclogincode;
}
- nginx,rewrite,proxy_pass,post数据,表单
- nginx中rewrite和proxy_pass
- nginx rewrite proxy_pass location 的理解
- nginx rewrite proxy_pass location 的理解
- nginx详细解读location rewrite和proxy_pass
- nginx rewrite导致post数据丢失
- nginx中location中关于proxy_pass和rewrite的应用
- nginx rewrite proxy_pass location实践及正则匹配
- nginx proxy_pass
- Nginx配置proxy_pass
- nginx proxy_pass 里的”/”
- Nginx配置proxy_pass
- Nginx配置proxy_pass
- Nginx的proxy_pass配置
- Nginx配置proxy_pass
- nginx 之 proxy_pass详解
- Nginx配置基础-proxy_pass
- nginx > proxy_pass : upstream
- 大话设计模式读书笔记之桥接模式
- JZOJ 5485 字符串
- 学习《JS高级程序设计》(5)——正则
- 将文件复制到ftp服务器时发生错误
- 使用synchronized实现死锁
- nginx,rewrite,proxy_pass,post数据,表单
- Spider Man CodeForces
- C++构造函数的三个作用
- L1-034. 点赞
- Android应用内多进程的使用及注意事项
- Asynchronous Methods for Deep Reinforcement Learning 阅读笔记
- $.ajax 中的contentType
- 使用ajax和json实现迭代数据的效果
- 使用eclipse插件创建一个web project