err-to-many-redirects at https



  • Good evening. Started ssl so that all requests could be redirected from https, but now there's a mistake ERR_TOO_MANY_REDIRECTS.

    Configuration:

    server {
        listen 80;
        listen 443 ssl;
    
    server_name jamesjgoodwin.ru www.jamesjgoodwin.ru;
    ssl on;
    ssl_certificate         /etc/ssl/jamesjgoodwin.crt;
    ssl_certificate_key     /etc/ssl/jamesjgoodwin.key;
    
    rewrite     ^   https://$server_name$request_uri? permanent;
    
    if ($http_host ~ "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") {
        return 444;
    }
    
    location / {
        proxy_pass http://127.0.0.1:81;
        index   index.html index.php;
    }
    
    location ~* \.(html|jpeg|jpg|gif|png|css|js|pdf|txt|tar|ico)$ {
        root /var/www/;
        expires 30d;
    }
    
    location ~ /.ht {
        deny all;
    }
    

    }



  • Try that, I didn't check the code, but in theory I have to work.

    server {
     listen 80;
    

    server_name jamesjgoodwin.ru www.jamesjgoodwin.ru;

    location / {
    rewrite ^(.*)$ https://example.com$1 permanent;
    }

    }

    server {
    listen 443 ssl;
    server_name jamesjgoodwin.ru www.jamesjgoodwin.ru;

    ssl on;
    ssl_certificate /etc/ssl/jamesjgoodwin.crt;
    ssl_certificate_key /etc/ssl/jamesjgoodwin.key;

    location / {
    proxy_pass http://127.0.0.1:81;
    index index.html index.php;
    }

    if ($http_host ~ "\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}") {
    return 444;
    }

    location ~* .(html|jpeg|jpg|gif|png|css|js|pdf|txt|tar|ico)$ {
    root /var/www/;
    expires 30d;
    }

    location ~ /.ht {
    deny all;
    }
    }


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2