Nginx not listen on IPv6 if not use HTTPS

AI-generated summary

User topological encountered an issue with Nginx not listening on IPv6 when not using HTTPS. The solution was to add listen [::]:80; to the Nginx configuration file, which is automatically included when using HTTPS templates (web.letsencrypt.ssl.template.yml and web.ssl.template.yml). topological suggested adding IPv6 support to non-HTTPS installs by modifying web.template.yml. However, pfaffman noted that Discourse mostly requires HTTPS and may not implement this feature. As a workaround, topological successfully added the necessary configuration to app.yml using a hook.

I set up a test server in an internal network (cannot be reached from outside, so cannot set up let’s encrypt), and I found that the nginx does not listen on IPv6 when the server has an IPv6 address. The /etc/nginx/conf.d/discourse.conf inside container shows listen 80; but no listen [::]:80;.

I have another production server which can be reached on IPv6 normally. And I have searched meta to find what is wrong with my test server configuration. Finally, I find that only if I add web.letsencrypt.ssl.template.yml and web.ssl.template.yml to my app.yml can I use IPv6 normally. The reason is that these files add listen [::]:80;. and listen [::]:443 ssl http2; in nginx configuration file.

The team can add IPv6 support to non-HTTPS install, i.e., add listen [::]:80; to web.template.yml.

Discourse mostly doesn’t work without https. They may not add the feature you request. But your can look at the ssl template to see what gets included to turn on ipv6 and add that code to your own template or the app.yml.

Yes, I tried to add to app.yml like this and it works.

hooks:
  after_web_config:
    - replace:
        filename: "/etc/nginx/conf.d/discourse.conf"
        from: /listen.+$/
        to: |
          listen 80;
          listen [::]:80;