Encode handler broken?

1. Caddy version (caddy version):

v2.4.4 h1:QBsN1jXEsCqRpKPBb8ebVnBNgPxwL50HINWWTuZ7evU=

2. How I run Caddy:

a. System environment:

amazon linux 2

d. My complete Caddyfile or JSON config:

{
    "apps": {
        "http": {
            "servers": {
                "srv0": {
                    "listen": [
                        ":443"
                    ],
                    "routes": [
                        {
                            "handle": [
                                {
                                "handler":"encode",
				"encodings":{"gzip":{},"zstd":{}},
                                "prefer":["zstd","gzip"]
                                },
                                {
                                "handler": "reverse_proxy",
                                "upstreams": [
                                    {
                                    "dial": "10.50.1.6:80"
                                    }
                                    ],
                                    "headers":{
                                      "response":{
                                         "set":{
                                            "Access-Control-Allow-Origin":["*"]
                                            }
                                         } 
                                    }
                                }
                            ]
                        }
                    ],
                    "tls_connection_policies": [
                        {}
                    ]
                }
            }
        },
        "tls": {
            "automation": {
               "policies": [
                    {
                        "issuers": [
                            {
                                "email": "support@ezot.com",
                                "module": "acme"
                            },
                            {
                                "email": "support@ezot.com",
                                "module": "zerossl"
                            }
                        ],
                        "on_demand": true
                    }
                ],
                "on_demand": {
                    "ask": "http://10.50.1.6/.check"
                }
            }
        }
    },
    "storage": {
        "module": "file_system",
        "root": "/certs/caddy/certmagic"
    }
}

3. The problem I’m having:

page content shows as gibberish due to compressed content being sent but no header added for content-encoding

4. Error messages and/or full log output:

5. What I already tried:

removing encode handler fixes the issue

6. Links to relevant resources:

Unfortunately, this is a known issue with v2.4.4.

Please revert to 2.4.3 for the time being.

@francislavoie Is the recommendation not to upgrade to 2.4.4 at all and instead wait for 2.4.5?

If you’re using encode and reverse_proxy in the same site, then you’ll have a problem. If you’re not, then you should be okay. This might include php_fastcgi now that I think of it (because under the hood, it also uses reverse_proxy), but I’m not sure.

when is the checked in fix going to be available for xcaddy builds?

It already is: encode: ignore flushing until after first write (#4318) · caddyserver/caddy@4ebf100 · GitHub

Just have xcaddy build at that commit.

1 Like

Not an xcaddy expert yet. How would one do that?

Like this:

$ xcaddy build <commit hash or branch name> \
    --with <plugin...> \
    --with <another plugin...>

So in this case, xcaddy build master or xcaddy build 43bf100 will do the trick

See the usage docs:

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