Skip to content

Conversation

@MayCXC
Copy link
Owner

@MayCXC MayCXC commented Nov 6, 2025

Assistance Disclosure

No AI was used.

Adds an interfaces subdirective to bind to implement caddyserver#7256 without changing how addresses are parsed:

example.com {
    bind 10.0.0.1 tcp4/127.0.0.1 tcp6/[::1] {
        interfaces eth0 tcp4/eth1 tcp6/eth2
        protocols h1 h2
    }
}

Only the first address is bound per prefix for interfaces assigned to a cidr. This is preferable to composing or selecting multiple addresses to emulate a bind to device syscall; a socket manager can do that natively with the overhead of opening 2^n listeners at once, or the unreliability of trying to open one of them iteratively. e.g. for linux, the user could use caddyserver#7340 with systemd.socket and BindToDevice/FreeBind.

Tests are todo, ideally we would mock the value of net.InterfaceByName and parse a caddyfile.

@MayCXC MayCXC closed this Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants