nginx - ngx.var is empty in openresty
滿天的星座
滿天的星座 2017-05-16 17:07:14
0
2
592
worker_processes  4;
error_log logs/error.log;

events {
    worker_connections 1024;
}

http {
    lua_package_path "/app/lua/?.lua;/usr/local/openresty/lualib/resty/?.lua;;";
    lua_code_cache off;

    server {
        listen 6699;
        charset utf-8;
        #lua_need_request_body on;

        location ~ ^/api/([-_a-zA-Z0-9/]+) {
            #echo $remote_addr;
            default_type application/json;
            access_by_lua_file  lua/bootstrap.lua;
            content_by_lua_file lua/.lua;
        }
    }
}

ngx.var in the lua script is an empty table

滿天的星座
滿天的星座

reply all(2)
大家讲道理

It is true that it cannot be printed, but it can be done individually, such as ngx.var.remote_addr, ngx.var.args (if the uri has parameters). Please give an expert answer as to why it cannot be printed. http://www.cnblogs.com/raiche ... These all seem to be OK

为情所困

I think the method of printing ngx.var is wrong. ngx.var is a table and a function needs to be implemented to print the table.

Reference
https://gist.github.com/range...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!