IPv6 with Lighttpd on Linux

February 15, 2010

The situation with lighttpd is sufficiently complicated that I can't call it a brief note, so here's what I've worked out. This is not necessarily valid for all distributions, since I'm working on Fedora 11.

Lighttpd is fully IPv6 enabled, but normally only binds its listening socket to the IPv4 address. Some distributions override this by setting the server.use-ipv6 configuration option if IPv6 is enabled on the machine.

Now, server.use-ipv6 is somewhat underdocumented; the lighttpd documentation says only 'bind to the IPv6 socket'. What it actually does at the moment is make lighttpd always create IPv6 sockets, regardless of what the socket is supposed to be bound to. (I am not sure how well this works if you are binding to specific IPv4 addresses, even on a dual binding machine with bindv6only turned off.)

Since lighttpd fully supports IPv6, you do not need to turn server.use-ipv6 on in order to bind to an IPv6 socket; instead, you simply tell lighttpd to do so by giving it an IPv6 address as server.bind or whatever. So if you have turned bindv6only on to turn off dual-binding and thus need to bind separately to both the IPv4 and the IPv6 sockets, you just need to tell lighttpd to do this by adding the following configuration bit:

$SERVER["socket"] == "[::]:80" { }

(As the lighttpd documentation dryly notes, 'note that it's perfectly valid to leave the body of the [$SERVER] conditional empty'. Lighttpd configuration is sometimes full of these magic side effects.)

This is sadly a lot more complicated than the Apache way, which can be described as 'it all just works, you don't have to worry about it' (cf the brief note).

Written on 15 February 2010.
« Brief notes on IPv6 support in some Linux programs
A Linux gotcha about daemons and bindv6only »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Mon Feb 15 01:23:17 2010
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.