Nginx occasional infinite redirects

I am finding issues of occasional infinite redirects with the following code. I am very confused as the problem does not occur consistently. It works on my devices and many online redirect checkers. Others however report an infinite redirect.

    listen         443 ssl http2;
    listen         [::]:443 ssl http2;
    ssl_certificate /etc/nginx/conf.d/cert/example.com.crt;
    ssl_certificate_key /etc/nginx/conf.d/cert/example.com.key;
    server_name    example.com;
    root           /var/www/example.com;
    index          index.html;
}

server {
    listen [::]:80;
    listen 80;
    server_name example.com www.example.com;
    return 302 https://example.com$request_uri;
}

server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;
    server_name www.example.com;
    return 302 https://example.com$request_uri;
}
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum