POST to an ip/path endpoint or perform curl command?

1. The problem I’m having:

I have an http endpoint on same vlan with caddy that triggers an action when accessing http://username:password@ip.ip.ip.ip:80/api?do=start&Key=12345

I want to be able to access and perform a POST to that endpoint over wan through caddy.

I have tried rewrite, redirect, and some other configs to no success.

Does caddy support proxying to a path endpoint like above? Or does caddy support performing curl commands when a particular address is requested? I do not need anything to be sent back to the user and only need to post the command to the ip path endpoint.

2. Error messages and/or full log output:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

3. Caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

4. How I installed and ran Caddy:

apt

a. System environment:

debian12

b. Command:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

c. Service/unit/compose file:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

d. My complete Caddy config:

https://subdomain.fqdn.com {
    reverse_proxy * http://usernam:password@ip.ip.ip.ip:80/api?do=start&Key=12345
}

5. Links to relevant resources:

You can try this (I’m typing it on a phone, so apologies about any typos):

https://subdomain.fqdn.com {
    rewrite * /api?do=start&Key=12345
    method /* POST
    request_header Authorization “Basic B64CREDS”
    reverse_proxy http://ip.ip.ip.ip:80
}

where B64CREDS is base64 encoded string:

username:password

Use this webpage only as an example of how to create B64CREDS!

You could also try this, maybe?

https://subdomain.fqdn.com {
    reverse_proxy * http://ip.ip.ip.ip:80 {
        rewrite /api?do=start&Key=12345
        method POST
        header_up Authorization “Basic B64CREDS”
    }
}

Hi, I very appreciate your posting and thanks for writing clearly on your phone.

After testing I found that the destination for the reverse proxy is not basic auth but it is digest auth. For testing I simply removed the lines with request_header Authorization .
In testing, caddy successfully proxied a browser client to the destination and the browser popped up an input box for username and password which appears to get passed to destination but then I get error 400 Bad Request.

I added a log line to the config ie
log {
output file /var/log/caddy/testing.log
level DEBUG
}

and caddy logs the error with access info however I do not see anything regarding the rewrite of the query parameters I was to be injected/appended.

{“level”:“error”,“ts”:1735880796.871118,“logger”:“http.log.access.log0”,“msg”:“handled request”,“request”:{“remote_ip”:“ip.ip.ip.ip”,“remote_port”:“46223”,“proto”:“HTTP/2.0”,“method”:“GET”,“host”:“subdomain.fqdn.com”,“uri”:“/”,“headers”:{“Upgrade-Insecure-Requests”:[“1”],“Sec-Fetch-Mode”:[“navigate”],“Sec-Fetch-Site”:[“cross-site”],“User-Agent”:[“Mozilla/5.0 (Android 12; Mobile; rv:133.0) Gecko/133.0 Firefox/133.0”],“Accept”:[“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8”],“Accept-Language”:[“en-US”],“Accept-Encoding”:[“gzip, deflate, br, zstd”],“Sec-Gpc”:[“1”],“Dnt”:[“1”],“Priority”:[“u=0, i”],“Te”:[“trailers”],“Authorization”:,“Sec-Fetch-Dest”:[“document”]},“tls”:{“resumed”:false,“version”:772,“cipher_suite”:4865,“proto”:“h2”,“server_name”:“subdomain.fqdn.com”}},“user_id”:“”,“duration”:0.004262169,“size”:226,“status”:400,“resp_headers”:{“Content-Length”:[“226”],“Date”:[“Fri, 03 Jan 2025 05:06:36 GMT”],“Content-Type”:[“text/html; charset=iso-8859-1”],“Server”:[“Caddy”,“Apache/2.4.41 (Unix) OpenSSL/1.0.2t”],“Alt-Svc”:[“h3=":443"; ma=2592000”]}}

I don’t believe the rewrite is working correctly and I need to do more testing.

I have read Global options (Caddyfile) — Caddy Documentation and don’t see what is missing for more verbose logging.
How can I log or get more verbose information on what operations caddy is performing regarding the rewrite because I do not see them in the log output file.