dimanche 28 novembre 2021

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;
}



Aucun commentaire:

Enregistrer un commentaire