Repository navigation
v2.22.0
Bind the server command to a specific address
The server command listened on every IPv4 interface, with no way to narrow it. --host now sets the IPv4 address it listens on, and the address applies to every --port (#528).
dewy server --registry ghr://owner/repo --host 127.0.0.1 --port 8000 -- /opt/app/current/app--hostrequires--port. Only an IPv4 unicast address is accepted: a hostname such aslocalhost, an IPv6 address, and a multicast or broadcast address are rejected at startup. The assets and container commands reject the option.0.0.0.0behaves the same as omitting the option, which is the default and listens on all IPv4 interfaces.- The
--health-pathcheck is sent to the given address, since a server bound to a specific interface does not accept connections on127.0.0.1. With0.0.0.0or no--host, it is still sent to127.0.0.1. The check no longer goes throughHTTP_PROXYorHTTPS_PROXY, so a proxy set for reaching a registry cannot answer it in place of the application. - With an address other than
0.0.0.0, theSERVER_STARTER_PORTenvironment variable passed to the application lists each socket ashost:port=fdinstead ofport=fd. An application that parses the variable itself must accept this form.
Nothing changes when --host is not set.
Documentation
- The multi-port and signal handling samples serve on the sockets passed by server-starter (#529). The Go samples bound their ports with
ListenAndServe, and the multi-port sample read the file descriptor inSERVER_STARTER_PORTas the port number. Under the server command, server-starter already holds the ports, so the samples left the configured ports unanswered, and binding the correct port fails with "address already in use" on Linux. The samples now turn each descriptor into anet.Listenerwithos.NewFileandnet.FileListenerand serve on it, which also keeps the ports open across a graceful restart.