XF 1.4 IP.Board to XenForo with NGINX

Hello all...

I've seem to run into a small problem while converting our site to XenForo. I cannot for the life of me get NGINX to pass old URL's to the ips2xf.php script.

I've tried to use the examples posted here, but have had no luck. Since we host our forums in the root directory, I modified those examples as follows:

Code:
    location = / {
        if ($uri ~* /(topic|forum|user)/) {
            rewrite ^ /ips2xf.php? last;
        }

        if ($args ~* (^|&)show(topic|forum|user)=) {
            rewrite ^ /ips2xf.php? last;
        }

        if ($args ~* ^/(topic|forum|user)/) {
            rewrite ^ /ips2xf.php? last;
        }    
    }

No luck. If I manually force an old URL through the ips2xf script, it works just fine.

Any ideas??? For some reason, I can't quite wrap my head around this one, even though I'm generally pretty good at figuring out how NGINX works.
 
You're doing an exact location match of /, so /topic/, etc won't actually match that.

You may be able to get away with just taking all the rewrites out of the location block, though I haven't tried to configure these rules in Nginx before.
 
Code:
server {
    listen   80;
    server_name beta.tvnewstalk.net
   
    access_log  /home/tvnewstalk/logs/access.log;
    error_log  /home/tvnewstalk/logs/error.log;
    rewrite_log on;

    root    /home/tvnewstalk/www/xf;

    gzip on;
    client_max_body_size 30M;

    # Main location
    location / {
        if ($uri ~* /(topic|forum|user)/) {
            rewrite ^ /ips2xf.php? last;
        }

        if ($args ~* (^|&)show(topic|forum|user)=) {
            rewrite ^ /ips2xf.php? last;
        }

        if ($args ~* ^/(topic|forum|user)/) {
            rewrite ^ /ips2xf.php? last;
        }    
    }   
       
    ## Static files location
    location ~* ^.+.(css|js|jpg|jpeg|gif|png|ico)$ {
        access_log off;
        log_not_found off;
        expires 30d;
    }

    location /uploads/gallery/ {
        log_not_found off;
        expires 7d;
    }

    location ~ \.php$ {
        try_files $uri = 404;
        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;
    }

}
 
The existing URL scheme looks like this:
Code:
http://forums.tvnewstalk.net/index.php?/topic/11429-out-and-about/
XenForo should look like this:
Code:
http://forums.tvnewstalk.net/index.php?threads/out-and-about.11429/

The IPB forum is on the forums. subdomain, where the XenForo board will be once I can get the redirects working.
 
Is there a different server block for forums.tvnewstalk.net? Because the nginx conf you posted shows this:

Code:
server_name beta.tvnewstalk.net

Other than that, the rules look correct. They just might be in the wrong block.
 
Is there a different server block for forums.tvnewstalk.net? Because the nginx conf you posted shows this:

Code:
server_name beta.tvnewstalk.net

Other than that, the rules look correct. They just might be in the wrong block.

beta is the test server, there's no use putting this in the forums. config right now, because the old IPB site is still running there until I can figure this out. In fact, let's pretend I never mentioned the forums subdomain since it doesn't contain anything regarding XenForo right now. Everything lives on Beta.

I have been testing the redirect script on Beta this way: Take a current URL:

Code:
http://forums.tvnewstalk.net/index.php?/forum/10-general-tv/

and switch the subdomain to "beta"

Code:
http://beta.tvnewstalk.net/index.php?/forum/10-general-tv/

Which should work. Beta is where the rewrite rules are. But all it does is send me to the Xenforo-generated 404 page without rewriting anything. If I change the URL to point directly at the redirect PHP script

Code:
http://beta.tvnewstalk.net/ipb2xf.php?/forum/10-general-tv/

The ipb2xf script triggers correctly and I end up in the right place.

So long story short, NGINX isn't rewriting the URLs at all on any domain (I did briefly have this same configuration running on forums, no luck), and I can't figure out why.
 
Last edited:
Top Bottom