caddy: Caddyfile v1 -> v2 reverse proxy don't work

1. Which version of Caddy are you using (caddy -version)?

commit 8de1a762273323608d9d9080c42057d1814070b6 (HEAD -> v2, tag: v2.0.0-beta10, origin/v2) Author: Matthew Holt mholt@users.noreply.github.com Date: Mon Nov 18 14:22:55 2019 -0700

2. What are you trying to do?

Changing V1 Caddyfile to V2 V1 Caddyfile woked fine BUT V2 reverse_proxy don’t work

3. What is your Caddyfile?

V1

https://www.daoyang.fun:443 {
        root /www

        proxy /helloworld https://127.0.0.1:42111 {
                header_upstream Host "www.daoyang.fun"
                header_upstream X-Forwarded-Proto "https"
                insecure_skip_verify
        }
}

V2

https://www.daoyang.fun {
    file_server {
        root /www
        browse
    }    

    reverse_proxy /helloworld 127.0.0.1:36601 {
       
        header_up Host www.daoyang.fun
        header_up X-Forwarded-Proto https
        transport http {
            tls_insecure_skip_verify
        }
    }
}

I think the two profiles only have proxy upstream of V1 with HTTPS and V2 reverse_proxy without. If I add HTTPS upstream of V2 like this

reverse_proxy /helloworld https://127.0.0.1:36601 {...}

then the service will report an error

2019/11/19 12:32:28.108 ERROR   http.log.error  dial https:: unknown network https:     {"request": {"method": "PUT", "uri": "/helloworld%0A", "proto": "HTTP/2.0", "remote_addr": "27.156.68.2:63751", "host": "www.daoyang.fun", "headers": {"Accept-Encoding": ["identity"], "User-Agent": ["Go-http-client/2.0"]}, "tls": {"resumed": false, "version": 772, "resumed": 4865, "proto": "h2", "proto_mutual": true, "server_name": "www.daoyang.fun"}}, "status": 502, "err_id": "mvuw2eebv", "err_trace": "reverseproxy.(*Handler).ServeHTTP (reverseproxy.go:330)"}

So I removed HTTPS from V2, and the proxy service did not respond even though there was no error in the service log

4. How did you run Caddy (give the full command and describe the execution environment)?

caddy run --config /www/Caddyfile --adapter caddyfile

5. Please paste any relevant HTTP request(s) here.

6. What did you expect to see?

reverse proxy can work

7. What did you see instead (give full error messages and/or log)?

nothing log and server don’t response correctly

8. Why is this a bug, and how do you think this should be fixed?

Can add https protocol in reverse_protocal like V1 version

9. What are you doing to work around the problem in the meantime?

10. Please link to any related issues, pull requests, and/or discussion.

Bonus: What do you use Caddy for? Why did you choose Caddy?

for v2ray h2 proxy

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 21 (11 by maintainers)

Most upvoted comments

@mholt Please forgive me for expressing ambiguity, because I don’t know much about the details. I may close this issue, and waiting people who have specific details submit an issue to you. Thanks for the reply.