1

We have certificate installed on ELB provided by AWS certificate services, also a self signed certificate is configured on Nginx web server. Now, when user comes to https://www.example.org/ it says

www.example.org redirected you too many times. ERR_TOO_MANY_REDIRECTS

following is my nginx conf file

server {
    listen 80;
    listen 443 ssl;
    server_name example.org www.example.org *.example.org;

    access_log /var/www/example.org/logs/access.log;
    error_log /var/www/example.org/logs/error.log;
    root /var/www/example.org/httpdocs;

    ssl_certificate      /etc/nginx/ssl/new/example.org.crt;
    ssl_certificate_key  /etc/nginx/ssl/new/example.org.key;
    ssl_protocols        TLSv1 TLSv1.1 TLSv1.2;

    location / {
        index index.html index.php;
        try_files $uri $uri/ @handler;
        expires 30d;
    }

    location @handler {
        rewrite / /index.php;
    }

    location ~ .php/ {
        rewrite ^(.*.php)/ $1 last;
    }
    location ~ .php$ {
        if (!-e $request_filename) { rewrite / /index.php last; }

        expires        off;
        fastcgi_param  HTTPS $fastcgi_https;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
  • What is the exact purpose of all those rewrite statements you have in the configuration? Most likely you have too many of them and they cause the issue. – Tero Kilkanen Dec 18 '16 at 12:05
  • Looks like the redirect is being done in slide php as your feeding the HTTPS state in as a variable. What's the ELB config? Is HTTPS being offloaded in the ELB. Does the redirect loop occur if you go to the website without the ELB? – Nath Dec 20 '16 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.