@@ -13,6 +13,12 @@ defmodule Plug.Cowboy do
1313 If you set an IPv6, the `:net` option will be automatically set to `:inet6`.
1414 If both `:net` and `:ip` options are given, make sure they are compatible
1515 (i.e. give a IPv4 for `:inet` and IPv6 for `:inet6`).
16+ Also, see "Loopback vs Public IP Addresses".
17+
18+ * `:ipv6_v6only` - a boolean value. If false, and if you bind to an IPv6
19+ address, Cowboy's underlying `:gen_tcp` call will also listen on IPv4.
20+ For example, binding to `{0, 0, 0, 0, 0, 0, 0, 0}` will also bind to
21+ `{0, 0, 0, 0}`. Defaults to false.
1622
1723 * `:port` - the port to run the server.
1824 Defaults to 4000 (http) and 4040 (https).
@@ -55,6 +61,33 @@ defmodule Plug.Cowboy do
5561 When using a unix socket, OTP 21+ is required for `Plug.Static` and
5662 `Plug.Conn.send_file/3` to behave correctly.
5763
64+ ## Loopback vs Public IP Addresses
65+
66+ Should your application bind to a loopback address, such as `::1` (IPv6) or
67+ `127.0.0.1` (IPv4), or a public one, such as `::0` (IPv6) or `0.0.0.0`
68+ (IPv4)? It depends on how (and whether) you want it to be reachable from
69+ other machines.
70+
71+ Loopback addresses are only reachable from the same host (`localhost` is
72+ usually configured to resolve to a loopback address).
73+ You may wish to use one if:
74+
75+ - Your app is running in a development environment (such as your laptop) and
76+ you don't want others on the same network to access it.
77+ - Your app is running in production, but behind a reverse proxy. For example,
78+ you might have Nginx bound to a public address and serving HTTPS, but
79+ forwarding the traffic to your application running on the same host. In that
80+ case, having your app bind to the loopback address means that Nginx can reach
81+ it, but outside traffic can only reach it via Nginx.
82+
83+ Public addresses are reachable from other hosts. You may wish to use one if:
84+
85+ - Your app is running in a container. In this case, its loopback address is
86+ reachable only from within the container; to be accessible from outside the
87+ container, it needs to bind to a public IP address.
88+ - Your app is running in production without a reverse proxy, using Cowboy's
89+ SSL support.
90+
5891 ## Instrumentation
5992
6093 Plug.Cowboy uses the `:telemetry` library for instrumentation. The following
0 commit comments