Listen on IPv6 in the image as well #136
No files matched your search
+3
-1
@@ -31,5 +31,7 @@ EXPOSE 8080
|
||||
# stays root's, which is why the entrypoint writes through the file rather
|
||||
# than replacing it.
|
||||
COPY --from=build --chown=101:101 /build/dist /usr/share/nginx/html
|
||||
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
# The nginx user's too, so listen-ipv6.sh can add the IPv6 listener at start.
|
||||
COPY --chown=101:101 docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --chmod=0755 docker/listen-ipv6.sh /docker-entrypoint.d/11-listen-ipv6.sh
|
||||
COPY --chmod=0755 docker/entrypoint.sh /docker-entrypoint.d/40-api-base-url.sh
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# Listen on IPv6 as well, when the host has it.
|
||||
#
|
||||
# nginx's own 10-listen-on-ipv6-by-default.sh does this only for the
|
||||
# default.conf it shipped, which ours replaces, so it skips it. The test is the
|
||||
# same one it uses: a kernel without IPv6 has no /proc/net/if_inet6, and nginx
|
||||
# refuses to start at all if asked to listen on an address family it cannot
|
||||
# open.
|
||||
set -eu
|
||||
|
||||
conf=/etc/nginx/conf.d/default.conf
|
||||
|
||||
[ -f /proc/net/if_inet6 ] || { echo "no IPv6 on this host, listening on IPv4 only"; exit 0; }
|
||||
grep -q 'listen \[::\]:8080' "$conf" && exit 0
|
||||
|
||||
# Written back through the file, as 40-api-base-url.sh does with index.html:
|
||||
# conf.d belongs to root, the file to the nginx user.
|
||||
tmp=$(mktemp)
|
||||
trap 'rm -f "$tmp"' EXIT
|
||||
sed 's|^\( *\)listen *8080;|&\n\1listen [::]:8080;|' "$conf" > "$tmp"
|
||||
cat "$tmp" > "$conf"
|
||||
|
||||
echo "listening on IPv6 as well"
|
||||
Reference in new issue
Block a user