Announcement

Collapse
No announcement yet.

https (ssl) on Nginx causes error 500 too_many_redirects with CMS stub

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [CMS] https (ssl) on Nginx causes error 500 too_many_redirects with CMS stub

    Issue:

    Attempting to use a CMS stub for the root directory. vBulletin is located in /forums.

    Stub works as expected with http, but as soon as I switch to https, error 500 "too_many_redirects" on the CMS stub. The rest of the site is flawless.

    Testing environment:
    • vBulletin 4.2.5 beta 1 (fresh install, no plugins/products/styles)
    • Standard options, standard URLs, example CMS.
    • Nginx
    • PHP 7.0
    • Cloudflare's free ssl (default settings)

    Test site is still available if you'd like a closer look.

    vhost
    Code:
    server {
            listen 80;
            listen [::]:80;
            listen 443 ssl;
            listen [::]:443 ssl;
    
            root /var/www/redacted;
    
            # Add index.php to the list if you are using PHP
            index index.php index.html index.htm index.nginx-debian.html;
    
            server_name www.redacted.com;
    
            location / {
                    # First attempt to serve request as file, then
                    # as directory, then fall back to displaying a 404.
                     try_files $uri $uri/ =404;
            }
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
            location ~ \.php$ {
                    include snippets/fastcgi-php.conf;
                    include snippets/phpstuff.conf;
            }
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            location ~ /\.ht {
                    deny all;
            }
    }
    fastcgi-php.conf
    Code:
    # regex to split $uri to $fastcgi_script_name and $fastcgi_path
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    
    # Check that the PHP script exists before passing it
    try_files $fastcgi_script_name =404;
    
    # Bypass the fact that try_files resets $fastcgi_path_info
    # see: http://trac.nginx.org/nginx/ticket/321
    set $path_info $fastcgi_path_info;
    fastcgi_param PATH_INFO $path_info;
    
    fastcgi_index index.php;
    include fastcgi.conf;

    phpstuff.conf
    Code:
                    # With php7.0-fpm:
                    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                    fastcgi_split_path_info ^(.+\.php)(.*)$;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    include fastcgi_params;
                    fastcgi_param QUERY_STRING $query_string;
                    fastcgi_param REQUEST_METHOD $request_method;
                    fastcgi_param CONTENT_TYPE $content_type;
                    fastcgi_param CONTENT_LENGTH $content_length;
                    fastcgi_intercept_errors on;
                    fastcgi_ignore_client_abort off;
                    fastcgi_connect_timeout 60;
                    fastcgi_send_timeout 180;
                    fastcgi_read_timeout 180;
                    fastcgi_buffers 256 16k;
                    fastcgi_buffer_size 32k;
                    fastcgi_temp_file_write_size 256k;
    I've spent all day trying different types of rewrite URLs and nginx configurations, all with the same result.It could be something to do with cloudflare (I'll test a normal SSL cert today), a bug with vBulletin, or some sort of server config I've missed.
    Last edited by sub_ubi; Sat 14th Jan '17, 2:35am.

  • #2
    What do you mean by "a CMS stub" ?

    cloudflare is a very likely suspect, cut them out and see what happens.
    Baby, I was born this way

    Comment


    • #3
      Hey Paul, you were right! It was cloudflare. "flexible" ssl causes the "too many redirects" issue. "Full" and "Full Strict SSL" fix the problem. I didn't have a SSL cert on my dev server so I just set one up, switched cloudflare to full and problem gone.

      Thank you again for the quick support, on a saturday no less.

      As for the CMS stub, I'm referring to this:
      https://www.vbulletin.com/docs/html/...insubdirectory
      Last edited by sub_ubi; Sat 14th Jan '17, 4:44pm.

      Comment


      • #4
        Personally I would ditch Cloudflare altogether. It causes all manner of problems, and every time you encounter an issue the first thing we are going to do is ask you to switch off Cloudflare.

        I have long been baffled as to why so many people want to use it. It causes nothing but trouble.
        MARK.B | vBULLETIN SUPPORT

        TalkNewsUK - My vBulletin 5.5.1 Demo
        AdminAmmo - My Cloud Demo

        Comment


        • #5
          The issue is that Cloudflare "flexible" is actually terminated SSL.
          In other words, the SSL terminates on their servers, and then the request is passed to your server as normal http.

          The code in vbulletin sees the http request, thinks it should be https, and so issues a redirect to https - thus a loop happens (hence too many redirects).

          Baby, I was born this way

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X