Why listen on 127.0.0.1 by default? #177
|
I'm setting up the socket proxy and one of the defaults is puzzling me (because it was the cause of an hour of debugging). In the readme, it's stated that "Socket-proxy listens per default only on 127.0.0.1. Depending on what you need, you may want to set another listener address with the -listenip parameter. In almost every use case, -listenip=0.0.0.0 will be the correct configuration when using socket-proxy in a docker image." Since the whole documentation and use is geared towards docker (it's a docker socket proxy so that makes sense) and is strongly recommending using 0.0.0.0, why is 127.0.0.1 the default listening parameter? I'm learning networking and the importance of default values as I set stuff up so it's a mix of genuine curiosity and a little bit of frustration. |
Replies: 3 comments 2 replies
|
The short version is that Loopback is scoped to a network namespace:
The important distinction is that binding Why not default to For the usual Compose setup, I would use all of these together:
If host access is required, the host-side mapping can still be restricted, for example So the default is deliberately about minimizing the consequence of a mistake. The documented Docker setting is about crossing container network namespaces. Both make sense, but the README could make that namespace distinction more explicit. |
|
Hi @NotaInutilis, thanks for your important input. As I'm not home until the end if August, just a short prelimitary reply. I have no intention of "gatekeeping". Initially I wrote the too for my own usage and designed it just to fit my needs. After a few years I learned a lot of how other people use it. With this knowledge maybe I would have designed some thins a little different. I will look after your suggestions as soon as I'll be home again. But I would aim to have no breaking changes. Maybe it would be a good idea if we started a new discussion thread to find out if there's a need for a redesigned version 2 with breaking changes. I would approach the subject very cautiously. Secondly, English is not my first language and documenting the own code for other users is not the easiest thing. Any help in. improving the documentation is highly appreciated :-) And a big thanks to @aleetreny for the great answer! Best reagards, |
|
I wanted ListenIP to be set explicitly to avoid any nasty surprises. Access to the Docker socket can have very serious consequences if permissions are configured incorrectly. For that reason, I believe security-sensitive software like this should rather not work at all than work insecurely. |

The short version is that
127.0.0.1is the safe default for the binary, while0.0.0.0is usually necessary for the common multi-container topology.Loopback is scoped to a network namespace:
127.0.0.1means only processes on that host can reach it.127.0.0.1means only processes inside that same container can reach it. A sibling Traefik or Dozzle container connects through the proxy container bridge interface, not its loopback interface, so the connection fails.0.0.0.0inside the container binds the bridge interface as well and makes sibling-container access possible.The important distinction is that binding
0.0.0.0…