9951 explained code solutions for 126 technologies


nginx-luaGet request header with Lua


server {
  location / {
    content_by_lua_block {
      ngx.say(ngx.req.get_headers()['Accept'])
    }
  }
}ctrl + c
content_by_lua_block

nginx-lua module directive to specify block of Lua code

ngx.say

output given text to client

ngx.req.get_headers()

returns table with request headers (online example)

'Accept'

sample header to get value of