Home  >  Q&A  >  body text

nginx - ngx.var is empty in openresty

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

滿天的星座滿天的星座2713 days ago598

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-05-16 17:09:14

    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

    reply
    0
  • 为情所困

    为情所困2017-05-16 17:09:14

    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...

    reply
    0
  • Cancelreply