In starting up a Vapor app, we specify a hostname to listen on. In the Dockerfile template this defaults to 0.0.0.0, which is IPv4 localhost. I'm wondering: is there a way to support listening on both 0.0.0.0 and ::?
Yup: listen on
IPv6 supports the idea of an "IPv4-mapped IPv6 address". So long as Vapor doesn't set the
IPV6_V6ONLY socket option (or its NIO spelling,
NIOBSDSocket.Option.ipv6_v6only then this will also listen on
0.0.0.0 and accept connections over both IPv6 and IPv4. The IPv4 connections will appear with "fake" IPv6 addresses that look like
Welp, it turns out that Vapor doesn't like IPv6. Just, you know, FYI. Sad face.
Building for debugging... Build complete! (7.90s) [ NOTICE ] Server starting on http://:::8080 (Vapor/HTTP/Server/HTTPServer.swift:277) [ WARNING ] unknown(host: "::", port: 8080) (Vapor/Application.swift:106) [ DEBUG ] Application shutting down (Vapor/Application.swift:135) Swift/ErrorType.swift:200: Fatal error: Error raised at top level: NIOCore.SocketAddressError.unknown(host: "::", port: 8080) Current stack trace: 0 libswiftCore.so 0x0000ffffb7365d94 _swift_stdlib_reportFatalErrorInFile + 128 1 libswiftCore.so 0x0000ffffb708fc2c _assertionFailure(_:_:file:line:flags:) + 300 2 libswiftCore.so 0x0000ffffb70f33bc Error<>._code.getter + 0 3 Run 0x0000aaaac25626c4 <unavailable> + 17770180 4 libc.so.6 0x0000ffffb6174c68 __libc_start_main + 232 5 Run 0x0000aaaac15d73f4 <unavailable> + 1471476
Are you sure this is Vapor? This is NIO reporting the error, which suggests that your system doesn't have IPv6 at all. Can you show me
ifconfig from within the container?