Skip to content

{http.request.remote.host} is empty when "Early-Data": "1" #6936

@condemil

Description

@condemil

I use Caddy as a proxy where "X-Real-IP" header is set to {http.request.remote.host}. When I see "Early-Data": "1" header present the "X-Real-IP" header becomes an empty string. I think it happens only with HTTP/3. In the same time, X-Forwarded-For still has valid IP address.

Caddy version: 2.9.1

Tested on latest chrome 135.0.7049.42.

Python script as a proxied app to reproduce the issue:

#!/usr/bin/env python3

import http.server
import json
import socketserver


class RequestHandler(http.server.BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header("Content-type", "text/plain")
        self.end_headers()
        self.wfile.write(json.dumps(dict(self.headers), indent=4).encode())


if __name__ == "__main__":
    PORT = 8000
    with socketserver.TCPServer(("", PORT), RequestHandler) as httpd:
        try:
            httpd.serve_forever()
        except KeyboardInterrupt:
            pass

Minimal caddy config to reproduce the issue:

{
    "apps": {
        "http": {
            "servers": {
                "public": {
                    "listen": [":443"],
                    "protocols": ["h3"],
                    "routes": [
                        {
                            "match": [
                                {
                                    "host": ["example.com"]
                                }
                            ],
                            "handle": [
                                {
                                    "handler": "reverse_proxy",
                                    "upstreams": [
                                        {
                                            "dial": "127.0.0.1:8000"
                                        }
                                    ],
                                    "headers": {
                                        "request": {
                                            "set": {
                                                "X-Real-IP": ["{http.request.remote.host}"]
                                            }
                                        }
                                    }
                                }
                            ],
                            "terminal": true
                        }
                    ]
                }
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation 📚Improvements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions