In reverse_proxy rewrite GET to POST and add payload to body

1. Output of caddy version:

v2.6.0-beta.3 h1:2VFvttWPkJPEhXep+4vtDLcevGs2gS7z41ruJGymaYI=

2. How I run Caddy:

From Konsole terminal.

a. System environment:

openSUSE Tumbleweed 20220820

b. Command:

caddy run --config Caddyfile.json --adapter ""

c. Service/unit/compose file:

N/A

d. My complete Caddy config:

{
  "apps": {
    "http": {
      "http_port": 8888,
      "servers": {
        "srv0": {
          "listen": [
            ":8888"
          ],
          "routes": [
            {
              "handle": [
                {
                  "handler": "headers",
                  "response": {
                    "set": {
                      "Access-Control-Allow-Origin": [
                        "*"
                      ]
                    }
                  }
                }
              ]
            },
            {
              "match": [
                {
                  "path": [
                    "/m2m/st/local/*"
                  ]
                }
              ],
              "handle": [
                {
                  "handler": "subroute",
                  "routes": [
                    {
                      "handle": [
                        {
                          "handler": "rewrite",
                          "method": "POST",
                          "strip_path_prefix": "/m2m/st/local"
                        }
                      ]
                    },
                    {
                      "handle": [
                        {
                          "handler": "reverse_proxy",
                          "transport": {
                            "dial_timeout": 20000000000,
                            "protocol": "http"
                          },
                          "upstreams": [
                            {
                              "dial": "localhost:8081"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    }
  }
}

3. The problem I’m having:

I’m using caddy as a reverse_proxy. Just a question.

I’m doing a POST to http://localhost:8888/m2m/st/local/system/healthcheck/tdv and that post includes an XML payload expected by the server

caddy redirects to http://localhost:8081/system/healthcheck/tdv

This works just fine.

My question is, can I convert the original request to caddy to a GET and have caddy change the GET to a POST and add the payload to the body to send to the server?

I can add

"method": "POST"

to the rewrite handler, but can’t find a way to add anything to the body.

4. Error messages and/or full log output:

N/A

5. What I already tried:

N/A

6. Links to relevant resources:

No there’s currently no way to add an arbitrary body to the proxy request.

I guess we could add that, but I think this is a really strange usecase. This should probably be something you do in your app instead, frankly. I’m not convinced it’s worth adding to Caddy.

Fair enough. I was wondering if this was reasonably or not.

Thanks