nginx lua 中赋值变量返回

nginx下:

 location /proxy{
                default_type 'text/plain';
                lua_code_cache off;

                set $appid '';//从lua里重写

                set_by_lua_file $url '/home/cq/share/xyx/nginx_example/nginx_server/lua/proxy.lua';

                #echo "url = $url";//从lua里赋值得到的url
                proxy_pass $url;
 }

lua下:

local a = ngx.var.arg_a;
local b = ngx.var.arg_b;
local c = ngx.var.arg_c;

ngx.header.content_type="text/plain";
ngx.var.appid = a;//写入到外部参数里

local uri = "https://api.weixin.qq.com/sns/jscode2session?app&secret="..b.."&js_code="..c.."&grant_type=authorization_code";

return uri;

反过来,在lua中获取nginx的变量

http {
    include       mime.types;
    default_type  application/octet-stream;
    #设定写入日志的内容,这里我为了看是否可以获取到headers中的Access-Token,这里只给日志中写入这一个值。
    log_format  main "$http_access_token";
    #设定日志的保存路径和日志模板,这里看不懂的话,看一看nginx日志的知识。
    access_log  logs/access.log  main;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen      80;
        server_name localhost;
        location / {
            root    html;
            index   index.html index.htm;
        }

        error_page  500 502 503 504  /50x.html;

        location /test {
            #content_by_lua_block表示{}内的代码,全部是lua代码
            content_by_lua_block {
                #用ngx.say输出ngx.var.http_access_token
                ngx.say("前端传过来的headers中的Access-Token的值是:", ngx.var.http_access_token)
            }
       }
   }
}