diff --git a/kong/dao/cassandra/apis.lua b/kong/dao/cassandra/apis.lua index 02fed92c073a..a936e6a907a1 100644 --- a/kong/dao/cassandra/apis.lua +++ b/kong/dao/cassandra/apis.lua @@ -9,9 +9,6 @@ local function validate_target_url(value) parsed_url.scheme = parsed_url.scheme:lower() if parsed_url.scheme == "http" or parsed_url.scheme == "https" then parsed_url.path = parsed_url.path or "/" - - print(url.build(parsed_url)) - return true, nil, { target_url = url.build(parsed_url)} else return false, "Supported protocols are HTTP and HTTPS" diff --git a/kong/kong.lua b/kong/kong.lua index 7cb7844859ab..0a852f2f9801 100644 --- a/kong/kong.lua +++ b/kong/kong.lua @@ -237,19 +237,22 @@ function _M.exec_plugins_log() -- Creating the log variable that will be serialized local message = { request = { + uri = ngx.var.request_uri, + request_uri = ngx.var.scheme.."://"..ngx.var.host..":"..ngx.var.server_port..ngx.var.request_uri, + querystring = ngx.req.get_uri_args(), -- parameters, as a table + method = ngx.req.get_method(), -- http method headers = ngx.req.get_headers(), size = ngx.var.request_length }, response = { + status = ngx.status, headers = ngx.resp.get_headers(), - size = ngx.var.body_bytes_sent + size = ngx.var.bytes_sent }, authenticated_entity = ngx.ctx.authenticated_entity, api = ngx.ctx.api, - ip = ngx.var.remote_addr, - status = ngx.status, - url = ngx.var.uri, - started_at = ngx.ctx.started_at + client_ip = ngx.var.remote_addr, + started_at = ngx.req.start_time() * 1000 } ngx.ctx.log_message = message diff --git a/spec/integration/proxy/realip_spec.lua b/spec/integration/proxy/realip_spec.lua index dc4a22b232e9..adf32b220e8c 100644 --- a/spec/integration/proxy/realip_spec.lua +++ b/spec/integration/proxy/realip_spec.lua @@ -61,7 +61,7 @@ describe("Real IP", function() assert.truthy(json_str) local log_message = cjson.decode(json_str) - assert.are.same("4.4.4.4", log_message.ip) + assert.are.same("4.4.4.4", log_message.client_ip) assert.are.same(uuid, log_message.request.headers.file_log_uuid) end) diff --git a/spec/plugins/logging_spec.lua b/spec/plugins/logging_spec.lua index e9fe55da1046..5a76e65d8bf3 100644 --- a/spec/plugins/logging_spec.lua +++ b/spec/plugins/logging_spec.lua @@ -58,7 +58,7 @@ describe("Logging Plugins", function() -- Making sure it's alright local log_message = cjson.decode(res) - assert.are.same("127.0.0.1", log_message.ip) + assert.are.same("127.0.0.1", log_message.client_ip) end) it("should log to UDP", function() @@ -75,7 +75,7 @@ describe("Logging Plugins", function() -- Making sure it's alright local log_message = cjson.decode(res) - assert.are.same("127.0.0.1", log_message.ip) + assert.are.same("127.0.0.1", log_message.client_ip) end) it("should log to HTTP", function() @@ -93,7 +93,7 @@ describe("Logging Plugins", function() -- Making sure it's alright assert.are.same("POST / HTTP/1.1", res[1]) local log_message = cjson.decode(res[7]) - assert.are.same("127.0.0.1", log_message.ip) + assert.are.same("127.0.0.1", log_message.client_ip) end) it("should log to file", function() @@ -124,7 +124,7 @@ describe("Logging Plugins", function() assert.truthy(json_str) local log_message = cjson.decode(json_str) - assert.are.same("127.0.0.1", log_message.ip) + assert.are.same("127.0.0.1", log_message.client_ip) assert.are.same(uuid, log_message.request.headers.file_log_uuid) end)