资料
- OpenResty® - 中文官方站
- OpenResty Github
- openresty/lua-nginx-module GitHub
- OpenResty 最佳实践-极客学院Wiki
- LuaJIT函数优化列表
- Lua 在线工具 | 菜鸟工具
- 基于nginx的api网关 - akin的博客 - 博客频道 - CSDN.NET
- 服务端架构中的“网关服务器” - 永远的朋友 - 51CTO技术博客
- Nginx配置文件(nginx.conf)配置详解 - 浮云中的神马 - 博客频道 - CSDN.NET
- 第二章 OpenResty(Nginx+Lua)开发入门 - 开涛的博客—公众号:kaitao-1234567,一如既往的干货分享 - ITeye技术网站
- Nginx担当WebSockets代理 - mfrbuaa - 博客园
- UrlEncode编码/UrlDecode解码 - 站长工具
- 如何在nginx中使用系统的环境变量(转) - 菜鸟刚起飞 - 博客频道 - CSDN.NET
- 请教一下关于 Nginx 反向代理到虚拟目录时如何处理使用绝对路径的静态文件 - V2EX
- nginx常用代理配置 - Florian - 博客园
- Module ngx_http_sub_module
- 编译nginx的源码安装subs_filter模块 - dudu - 博客园
问题
WebSocket代理
在入口nginx.conf中添加配置
1 | map $http_upgrade $connection_upgrade { |
1 | # add for websocket of paas |
双层Nginx URI被修改问题
初始请求URI
1 | /winery/servicetemplates/http%253A%252F%252Fwww.zte.com.cn%252Fpaas%252Fr3%252Fservice%252Fopenabtest%252Flatest/112/topologytemplate/?edit |
到第二层后变为解码后的(解码地址)
1 | /winery/servicetemplates/http%3A%2F%2Fwww.zte.com.cn%2Fpaas%2Fr3%2Fservice%2Fopenabtest%2Flatest/112/topologytemplate/?edit |
测试如下:
本地一层nginx代理成功,无此问题
将Access层去掉后,无此问题
问题定位Access层。
中间日志设置无效。
在第二层的location接口修改
1 | location /winery/ { |
这样就会收到的request请求是否正确
然后利用curl命令访问第一层
1 | curl localhost:8384/winery/servicetemplates/http%253A%252F%252Fwww.zte.com.cn%252Fpaas%252Fr3%252Fservice%252Fopenabtest%252Flatest/112/topologytemplate/?edit |
发现返回如下
1 | /winery/servicetemplates/http%3A%2F%2Fwww.zte.com.cn%2Fpaas%2Fr3%2Fservice%2Fopenabtest%2Flatest/112/topologytemplate/?edit |
解决办法:
1 | location ~* (.*) { |
$1
是正则匹配中第一个括号内的东西,args
是?后的参数。
发现正则匹配中会将uri进行解码,导致$1
中放入解码后的文本。
解决方法1:
将15行的/$1?$args
改为$request_uri
解决方法2:
将1行的location改为location / {
,同时将15行的/$1?$args
删除。
修改后curl返回为
1 | /winery/servicetemplates/http%253A%252F%252Fwww.zte.com.cn%252Fpaas%252Fr3%252Fservice%252Fopenabtest%252Flatest/112/topologytemplate/?edit |