@@ -93,6 +93,28 @@ find_nss_wrapper() {
9393 return 1
9494}
9595
96+ ipv6_available () {
97+ WEBLATE_NGINX_IPV6_VALUE=$( printf ' %s' " ${WEBLATE_NGINX_IPV6:- auto} " | tr ' [:upper:]' ' [:lower:]' )
98+
99+ if [ " $WEBLATE_NGINX_IPV6_VALUE " = " 0" ] || [ " $WEBLATE_NGINX_IPV6_VALUE " = " false" ] || [ " $WEBLATE_NGINX_IPV6_VALUE " = " no" ] || [ " $WEBLATE_NGINX_IPV6_VALUE " = " off" ]; then
100+ return 1
101+ fi
102+
103+ if [ " $WEBLATE_NGINX_IPV6_VALUE " = " 1" ] || [ " $WEBLATE_NGINX_IPV6_VALUE " = " true" ] || [ " $WEBLATE_NGINX_IPV6_VALUE " = " yes" ] || [ " $WEBLATE_NGINX_IPV6_VALUE " = " on" ]; then
104+ return 0
105+ fi
106+
107+ if [ ! -f /proc/net/if_inet6 ]; then
108+ return 1
109+ fi
110+
111+ if [ -r /proc/sys/net/ipv6/conf/all/disable_ipv6 ] && [ " $( cat /proc/sys/net/ipv6/conf/all/disable_ipv6) " = " 1" ]; then
112+ return 1
113+ fi
114+
115+ return 0
116+ }
117+
96118# Support OpenShift and other arbitrary-UID deployments without modifying
97119# the system passwd database. Keep the legacy /etc/passwd append only as a
98120# compatibility fallback for derived images that still make it writable.
@@ -315,6 +337,7 @@ if [ "$1" = "runserver" ]; then
315337 WEBLATE_REALIP="
316338real_ip_header X-Forwarded-For;
317339set_real_ip_from 0.0.0.0/0;
340+ set_real_ip_from ::/0;
318341"
319342 ;;
320343 * )
@@ -336,10 +359,27 @@ set_real_ip_from 0.0.0.0/0;
336359 # Make sure WEBLATE_ANUBIS_URL is set
337360 : " ${WEBLATE_ANUBIS_URL:= " " } "
338361 : " ${WEBLATE_ENABLE_HTTPS:= " " } "
362+ if ipv6_available; then
363+ WEBLATE_ENABLE_IPV6=1
364+ else
365+ WEBLATE_ENABLE_IPV6=
366+ fi
339367
340368 # Generate nginx configuration
341369 mkdir -p /tmp/nginx
342- /app/venv/bin/python /etc/nginx/generate-site.py /etc/nginx " $WEBLATE_URL_PREFIX " " $WEBLATE_REALIP " " $CLIENT_MAX_BODY_SIZE " " $WEBLATE_BUILTIN_SSL " " $WEBLATE_ANUBIS_URL " " $WEBLATE_SITE_DOMAIN " " $WEBLATE_ENABLE_HTTPS " " $GRANIAN_SOCKET " > /tmp/nginx/weblate-site.conf
370+ /app/venv/bin/python \
371+ /etc/nginx/generate-site.py \
372+ /etc/nginx \
373+ " $WEBLATE_URL_PREFIX " \
374+ " $WEBLATE_REALIP " \
375+ " $CLIENT_MAX_BODY_SIZE " \
376+ " $WEBLATE_BUILTIN_SSL " \
377+ " $WEBLATE_ANUBIS_URL " \
378+ " $WEBLATE_SITE_DOMAIN " \
379+ " $WEBLATE_ENABLE_HTTPS " \
380+ " $GRANIAN_SOCKET " \
381+ " $WEBLATE_ENABLE_IPV6 " \
382+ > /tmp/nginx/weblate-site.conf
343383
344384 # Calculate number of processes, at least 2, at most 4, depending on CPU cores
345385 if [ -z " $WEBLATE_WORKERS " ]; then
0 commit comments