How to use different schemes for load balancing in Caddy?

1. The problem I’m having:

I need to use Caddy for reverse proxy and load balancing. After configuring it, it prompts that the scheme must be the same. I have two target addresses: 127.0.0.1, which is located on the local machine, and another one is a domain on remote machine, which is on another server.
When I remove the “http://” prefix from “http://127.0.0.1:4020”, Caddy can start normally, but when I try to access it, I get a 502 error and a TLS error. If I add the prefix back, it prompts that the scheme must be the same. I’ve tried many methods, but none of them work. I couldn’t find any relevant solutions on Google, and the answers provided by ChatGPT didn’t work either.
So what should I do? Thank you very much!

2. Error messages and/or full log output:

reload: adapting config using caddyfile: parsing caddyfile tokens for 'reverse_proxy': Caddyfile:28 - Error during parsing: for now, all proxy upstreams must use the same scheme (transport protocol); expecting 'http://' but got 'https://'

3. Caddy version:

v2.4.6

4. How I installed and ran Caddy:

binary file.
./caddy start

a. System environment:

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:

aaa.com443 {
    reverse_proxy {
        to http://127.0.0.1:4020
        to https://The domain name pointing to another server.
        lb_policy random
    }
}

5. Links to relevant resources:

It’s not possible to load balance between upstreams with different transport requirements. They must both be HTTP or both be HTTPS.

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