From 7a7c47eefaf2d9a2b573f42e7bfb31bfe7402250 Mon Sep 17 00:00:00 2001
From: Michael Brown <supermathie@gmail.com>
Date: Tue, 4 Apr 2023 13:36:41 -0400
Subject: [PATCH] Add template to enable an IPv6 listener

By default nginx in the container only listens for IPv4 connections. Some users
want to enable direct IPv6 connectivity to the container either via forwarding
or NAT. This provides an easy method to allow that.
---
 samples/standalone.yml          | 4 +++-
 samples/web_only.yml            | 4 +++-
 templates/web.ipv6.template.yml | 8 ++++++++
 3 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 templates/web.ipv6.template.yml

diff --git a/samples/standalone.yml b/samples/standalone.yml
index 80adeaf..2ba6d15 100644
--- a/samples/standalone.yml
+++ b/samples/standalone.yml
@@ -11,8 +11,10 @@ templates:
   - "templates/postgres.template.yml"
   - "templates/redis.template.yml"
   - "templates/web.template.yml"
+  ## Uncomment the next line to enable the IPv6 listener
+  #- "templates/web.ipv6.template.yml"
   - "templates/web.ratelimited.template.yml"
-## Uncomment these two lines if you wish to add Lets Encrypt (https)
+  ## Uncomment these two lines if you wish to add Lets Encrypt (https)
   #- "templates/web.ssl.template.yml"
   #- "templates/web.letsencrypt.ssl.template.yml"
 
diff --git a/samples/web_only.yml b/samples/web_only.yml
index 08e4171..ea83093 100644
--- a/samples/web_only.yml
+++ b/samples/web_only.yml
@@ -3,8 +3,10 @@
 
 templates:
   - "templates/web.template.yml"
+  ## Uncomment the next line to enable the IPv6 listener
+  #- "templates/web.ipv6.template.yml"
   - "templates/web.ratelimited.template.yml"
-## Uncomment these two lines if you wish to add Lets Encrypt (https)
+  ## Uncomment these two lines if you wish to add Lets Encrypt (https)
   #- "templates/web.ssl.template.yml"
   #- "templates/web.letsencrypt.ssl.template.yml"
 
diff --git a/templates/web.ipv6.template.yml b/templates/web.ipv6.template.yml
new file mode 100644
index 0000000..bf589fe
--- /dev/null
+++ b/templates/web.ipv6.template.yml
@@ -0,0 +1,8 @@
+run:
+  - exec: echo "Enabling IPv6 listener"
+  - replace:
+      filename: "/etc/nginx/conf.d/discourse.conf"
+      from: listen 80;
+      to: |
+        listen 80;
+        listen [::]:80;
-- 
2.25.1