How to reverseproxy to htttp1?

1. Caddy version (caddy version): 2.4.5 alpine

2. How I run Caddy: Docker

a. System environment: Docker linux

b. Command:

c. Service/unit/compose file: docker docker compose

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

app.localhost  {
    file_server browse
    # reverse_proxy
localhost {
    reverse_proxy {

3. The problem I’m having:

file_server browse works fine, but the reverse proxy is not working i think its because my backend server is Golang Fiber which does not support http2 . How i can tell to reverse proxy using http1 ?

4. Error messages and/or full log output:

{“level”:“error”,“ts”:1635821206.3486726,“logger”:“http.log.error”,“msg”:“dial tcp connect: connection refused”,“request”:{“remote_addr”:“”,“proto”:“HTTP/2.0”,“method”:“OPTIONS”,“host”:“localhost”,“uri”:"/core/api/v1/open/login",“headers”:{“Sec-Fetch-Site”:[“cross-site”],“Accept-Language”:[“en-US,en;q=0.5”],“Accept-Encoding”:[“gzip, deflate, br”],“Sec-Fetch-Mode”:[“cors”],“Te”:[“trailers”],“User-Agent”:[“Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0”],“Access-Control-Request-Headers”:[“content-type”],“Dnt”:[“1”],“Accept”:["/"],“Sec-Gpc”:[“1”],“Sec-Fetch-Dest”:[“empty”],“Access-Control-Request-Method”:[“POST”],“Referer”:[“http://localhost:9000/"],“Origin”:[“http://localhost:9000”]},“tls”:{“resumed”:false,“version”:772,“cipher_suite”:4865,“proto”:“h2”,“proto_mutual”:true,“server_name”:“localhost”}},“duration”:0.000403205,“status”:502,“err_id”:“cr0wg9kk3”,“err_trace”:"reverseproxy.statusError (reverseproxy.go:858)”}

5. What I already tried:

6. Links to relevant resources:

The HTTP/2.0 you see in the logs is for the request coming into Caddy, not the proxy request.

The actual error is that Caddy wasn’t able to connect to your upstream at all, it wasn’t a protocol issue but a connection issue.

Make sure your Caddy container is in the same network at your other containers you’re trying to proxy to. I recommend using the container name rather than the IP address to connect to other containers, because the IP address is ephemeral (Docker will give containers whatever IP it feels like on startup), but the container name is reliable (as long as you run it in the same docker network)

Next time, please properly fill out the help topic template. You left out a lot of details, like how you’re actually running your Docker containers, and you didn’t use code formatting for your logs which makes it messy and the forum turned part of it into a link. Make sure to put ``` on their own lines, before and after your config and logs.

This topic was automatically closed after 30 days. New replies are no longer allowed.