Chen
Chen

Reputation: 21

Envoy Lua Filter - How to make HTTP request?

I would like to make http request from my lua filter to an external server. According to Envoy documentation, http call can be done using request_handle:httpCall:

function envoy_on_request(request_handle)
  -- Make an HTTP call to an upstream host with the following headers, body, and timeout.
  local headers, body = request_handle:httpCall(
  "lua_cluster",
  {
    [":method"] = "POST",
    [":path"] = "/",
    [":authority"] = "lua_cluster"
  },
  "hello world",
  5000)

I have created a cluster called lua_cluster in my envoy.yaml file as needed, but the request doesn't reach my server and I'm getting 400 response.

Possible solution??

When changing the authority header from [":authority"] = "lua_cluster" to [":authority"] = "<cluster's url hostname>", the request arrived to the server and I got 200 response from the server. Can someone explain this? Is it a valid thing to do?

Upvotes: 2

Views: 1204

Answers (0)

Related Questions