lua entry thread aborted: runtime error: content_by_lua(default.conf:31):2: attempt to call field 'get_headers' (a nil value)

    location / {
        #root   /usr/local/openresty/nginx/html;
        #index  index.html index.htm;
    
        proxy_set_header X-Real-IP $remote_addr;
        default_type text/html;
        content_by_lua '
            ngx.say(ngx.req.get_headers()["X-real-ip"])
        ';
    }

    这是我nginx里面的代码

      ===test==http_version:
      ===test==raw_header:
      ===test==set_header:
      ===test==set_uri:
      ===test==set_uri_args:
      ===test==get_post_args:
      ===test==read_body:
      ===test==discard_body:
      ===test==get_body_data:
      ===test==get_body_file:
      ===test==set_body_data:
      ===test==set_body_file:
      ===test==init_body:
      ===test==append_body:
      ===test==finish_body:
      ===test==socket:
      ===test==is_internal:

      没有get_headers。。。。。。_

        10 days later

        proxy_set_header 是为上游的服务器设置请求头,无法在 content_by_lua 阶段获取到该内容

          Write a Reply...