smocker icon indicating copy to clipboard operation
smocker copied to clipboard

Dynamic proxy?

Open Laski opened this issue 1 year ago • 1 comments

I'm trying to combine the "dynamic_mock" and "proxy" resources. My objective is to route the requests wherever the HOST header says.

e.g.

request:
  method: GET
  path: /example
dynamic_response:
  engine: lua
  script: |-
    require "math"
    return {
      proxy = {
        host = ..request.headers.host,
        follow_redirects = true
      }
    }

or

request:
  method: GET
  path: /example
dynamic_response:
  engine: go_template_yaml
  script: |
    proxy:
      host: {{.Request.Headers.Get "Host"}}
      follow_redirect: true

neither of this seem to work (the response is actually 200 but empty).

Maybe I should note that hardcoding the host part doesn't seem to work either.

Is this a supported use case?

Laski avatar Feb 05 '24 15:02 Laski

Hi @Laski,

dynamic_responses only allow to generate a response, not a proxy.

There's no real way to handle "dynamic proxy" for now.

Thiht avatar Mar 19 '24 17:03 Thiht