feat: Listen on Unix Socket
This pull request adds support for running the server on a Unix socket in addition to the existing TCP host:port option. The configuration, startup logic, and documentation have been updated to support this new mode while keeping validation strict to ensure only one listening method is used.
Server listening mode enhancements
- Added support for listening on a Unix socket via the new
socket-pathconfiguration property inconfig.go, with validation to ensure that only one ofsocket-pathorhost:portis specified. [1] [2] - Modified server startup logic in
glance.goto handle Unix socket creation and cleanup, and to select between TCP and Unix socket based on configuration. [1] [2]
Documentation updates
- Updated
docs/configuration.mdto document the newsocket-pathoption. - Added configuration examples for both TCP and Unix socket modes, and clarified that only one mode may be enabled at a time. [1] [2]
Why Unix sockets?
The main motivation for this feature is to simplify reverse proxy setups. For example, a proxy (such as Caddy or Nginx) can be configured to talk directly to the server over a Unix domain socket instead of a TCP port. This avoids the need to open or manage additional firewall rules, which is especially convenient in NixOS environments or when running in containers.
More generally, Unix sockets provide:
- No TCP port required → reduced attack surface and simpler firewalling.
- Lower overhead for local communication (no IP stack traversal).
- File system–based access control via standard Unix permissions.
- A good fit for sandboxed/containerized deployments where networking may be restricted.
Any Feedback welcome :smile: