spacewander commented on issue #3051:
URL: https://github.com/apache/apisix/issues/3051#issuecomment-745129118


   I tried it by myself. I can successfully get the host. 
   I got `2020/12/15 16:12:58 [alert] 25603#25603: *24 [lua] key-auth.lua:82: 
phase_func(): localhost, client: 127.0.0.1, server: localhost, request: \"GET 
/hello HTTP/1.1\", host: \"localhost\"` with change:
   ```patch
   diff --git apisix/plugins/key-auth.lua apisix/plugins/key-auth.lua
   index ab314a9..db1dda3 100644
   --- apisix/plugins/key-auth.lua
   +++ apisix/plugins/key-auth.lua
   @@ -78,7 +78,8 @@ end
   
   
    function _M.rewrite(conf, ctx)
   -    local key = core.request.header(ctx, "apikey")
   +    local key = core.request.get_host(ctx)
   +    ngx.log(ngx.ALERT, key)
        if not key then
            return 401, {message = "Missing API key found in request"}
        end
   ```
   
   Not sure why it doesn't take effect. Please reopen the issue if you can 
provide a runnable example.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to