Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

set_by_lua #8

Open
wangwj opened this issue Mar 22, 2017 · 6 comments
Open

set_by_lua #8

wangwj opened this issue Mar 22, 2017 · 6 comments

Comments

@wangwj
Copy link

wangwj commented Mar 22, 2017

location / {
好像不支持 set_by_lua指令,想用这个指令实现如下效果
set_by_lua $cur_ups '
url中取一个固定参数的值
'
proxy_pass $scheme://$cur_ups;
}
这样我就可以通过参数的不一样,动态的跳转到对应的upstream

@yejingx
Copy link
Contributor

yejingx commented Mar 22, 2017

可以支持 set_by_lua 的。

@wangwj
Copy link
Author

wangwj commented Mar 27, 2017

@yejingx 是我用的方式不对吗,下面是配置,执行ngins -s reload 后直接报错
server {
listen 8080 default_server;
access_log logs/access.log main;

set $x_error_code "-";

proxy_next_upstream_tries 2;
proxy_next_upstream_timeout 5s;
proxy_next_upstream error timeout http_502;

proxy_read_timeout 60s;

rewrite_by_lua_file app/src/rewrite.lua;

location / {
    set_by_lua_block $abc {
            return aaa;
    };
    proxy_pass  http://backend;

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

}

执行命令 /usr/local/slardar/nginx/sbin/nginx -s reload
nginx: [emerg] unknown directive "set_by_lua_block" in /usr/local/slardar/nginx/conf/slardar/service.conf:19

@yejingx
Copy link
Contributor

yejingx commented Mar 28, 2017

@wangwj 检查下你的 lua-nginx-module 版本是否大于 v0.9.17。

@wangwj
Copy link
Author

wangwj commented Mar 28, 2017

@yejingx 感谢回复,我直接用的是maser源码编译的,我已经确认过了,set_by_lua 也是不能用的,我看了我们的编译的依赖版本配置0.10.6rc1,配置如下,确实无法识别,我也是比较纳闷,原理上应该是支持的
V_PCRE=8.39
V_NGINX=1.9.15
V_LUAJIT=2.1-20150223
V_LUA_CJSON=2.1.0
V_NGX_LUA_MODULE=0.10.6rc1
V_CMSGPACK=f5b838ac552cbada957749d6938cd96a4e7a1f62
V_LUASOCKET=3.0-rc1

@wangwj
Copy link
Author

wangwj commented Mar 28, 2017

估计是找到问题了,应该是编译少ndk的相关东西,https://github.com/simpl/ngx_devel_kit

@yejingx
Copy link
Contributor

yejingx commented Mar 28, 2017

恩,看到文档里的说明了:

This directive requires the ngx_devel_kit module.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants