Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

"This webpage has a redirect loop." on vanilla rc3 install, nginx

eleitheleith New
edited July 2010 in Vanilla 2.0 - 2.8
i've got a working vanilla 2 (pre RC1) running, but i can not get the latest RC3 running. i'm trying out on a fresh install, i have all the pre-requisites.

i'm running of a subdomain and am accessing the site expecting to get the setup form, but instead i get the message

"This webpage has a redirect loop.

The webpage at http://forum2.diffbot.com/index.php?p=/dashboard/setup has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer."

the page looks like it is just redirecting to itself. i'm running nginx, the default install shouldn't be trying to do any rewriting on the URLs. any idea on where should i begin looking, perhaps i can push a fix through if i can figure out where to look.

Comments

  • ToddTodd Vanilla Staff
    Nginx is a server we definitely need to test and support. Can you by any chance give us the name of your host so we can see if we can get a test account with them @eleith?
  • @todd, i run my own nginx server.

    i've debugged problems with the pre-RC versions of vanilla 2 and posted a working conf in a popular thread here. more than willing to debug again, just need some pointers as things have changed a bit since pre-RC (for example, redirects are for ?p= as noted in the .htaccess file)
  • ToddTodd Vanilla Staff
    Okay thanks! Yes, we've changed the url structure to have the request path be in the p querystring parameter as this will ensure php doesn't mess with it. So I guess you'll have to change your nginx config file to have that format too.

    Another place that it could be redirecting would be in /bootstrap.php near line 92 here:
    if(!Gdn::Config('Garden.Installed', FALSE) && strpos(Gdn_Url::Request(), 'setup') === FALSE) {
    header('location: '.Gdn::Request()->Url('dashboard/setup', TRUE));
    exit();
    }
    Can you maybe put a die(Gdn_Url::Request().'|'.Gdn::Request()->Url('dashboard/setup', TRUE)); before that if statement and see tell me what it says? I'm not sure the request is being identified properly.
  • Gdn_Url::Request() == "" [empty string]
    Gdn::Request()->Url('dasbhoard/setup', True) == "/index.php?p=/dashboard/setup"

    does this indicate that nginx is not passing PATH_INFO correctly?
  • @todd, ok, i have now successfully installed a fresh rc3 on nginx. but i had to change up code in class.request.php in function _LoadEnvironment to get it working (as well as a slightly modified nginx.conf for my site.

    the line that states (305 in mine) in class.request.php

    if (!isset($_SERVER['SHELL'])) {
    always skips an important environment loading section for me, and then my request scheme gets set as 'console' which means further checks as to the domain/host/path all return empty string.

    for me, shell is always set, so i changed the line to

    if (isset($_SERVER['SHELL'])) {
    and then my environment gets set, and i can now get vanilla installed (with rewrite working perfectly)

    here is a section in my nginx.conf that gets it working with vanilla


    server {
    listen 80;
    server_name forum.example.com;

    root /path/to/Garden;
    index index.php index.html;

    #error_page 404 /404.html;
    # redirect server error pages to the static page /50x.html
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /var/www/nginx-default;
    }

    location / {

    if (-f $request_filename) {
    break;
    }

    if (-d $request_filename) {
    break;
    }

    rewrite ^(.+)$ /index.php?p=$1 last;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php($|/) {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include /etc/nginx/fastcgi_params;

    set $script $uri;
    set $path_info "";

    if ($uri ~ "^(.+\.php)\?p=(/.+)") {
    set $script $1;
    set $path_info $2;
    }

    fastcgi_param SCRIPT_FILENAME $document_root$script;
    fastcgi_param SCRIPT_NAME $script;
    fastcgi_param PATH_INFO $path_info;
    }
    }

    i believe the code i changed is to separate for when the application is called internally versus through a web server, so there is an expectation that webservers do not set SHELL ?
  • ToddTodd Vanilla Staff
    Thanks for the catch. We had started programming console support, but never completed it and I guess this shows that other web servers still have other variables that might interfere.

    I've removed the incomplete console support and pushed another copy of Gdn_Request to nightly. @eleith, can you grab the latest source from http://vanillaforums.org/download/nightly and try the new /library/core/class.request.php file?
  • @todd, i can confirm the changes in that one particular file works for me on a new install
  • ToddTodd Vanilla Staff
    Awesome, thanks.
Sign In or Register to comment.