This is a discussion on howto for nginx within the General Discussion forums, part of the vBulletin SEO Discussion category; Originally Posted by Stubbed IfIsEvil ^-- With that in mind, is there another way to achieve this? Would also like ...
FYI - the latest vBSEO download includes nginx redir rules...
But... They're a bit sick. I won't bother with a support request as this is just on my testing site (Obviously will log one if required), but the ones that came with the download return 500 error.
Supplied with 3.6.0:
Error from logs:Code:location /forums/ { rewrite ^/forums/((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ /forums/vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 last; try_files $uri $uri/ /forums/vbseo.php?$args; } location ~ /forums/(.*\.php)$ { rewrite ^/forums/(.*)$ /forums/vbseo.php last; } location /forums/vbseo/(includes|resources/html|resources/xml)/ { allow 127.0.0.1; deny all; }^-- I realise that's from the admincp but it was the same on the forum.Code:2011/05/07 15:31:11 [error] 12304#0: *35 rewrite or internal redirection cycle while processing "/forums/vbseo.php", client: 123.xxx.xxx.xxx, server: site.com, request: "GET /forums/vbseocp.php HTTP/1.1", host: "site.com", referrer: "http://site.com/forums/admincp/index.php?do=nav"
From nginx docs:Looking at that, it looks like it's hitting the first location, and then the second one, and so on and so on. Removing the second location directive makes everything operable again, and I can't figure out a situation where you would need the location of "~ /forums/(.*\.php)$" over just "/forums/" ?If the directives of this module are given at the server level, then they are carried out before the location of the request is determined. If in that selected location there are further rewrite directives, then they also are carried out. If the URI changed as a result of the execution of directives inside location, then location is again determined for the new URI.
This cycle can be repeated up to 10 times, after which Nginx returns a 500 error.
What am I missing here?
I'm going to bump this thread since it will probably save me some time. I have the exact problem of the last person who posted before me. Does anyone know how to fix this?
I can't remember the exact outcome, but these were the rules provided to me by vBSEO that worked (I also moved my /forum/ directory to just /, which is the first rule):
The problem was this broke a lot of third party apps that I had that had to be inside my forum directory in order to integrate with vBulletin, which is a shame. Default fastcgi_params file.Code:location /forum/ { rewrite ^/forum/(.*)$ http://site.com/$1 permanent; } location / { rewrite ^/((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ /vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 last; try_files $uri $uri/ /vbseo.php?$args; } location /vbseo/(includes|resources/html|resources/xml)/ { allow 127.0.0.1; deny all; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/tmp/php5.sock; fastcgi_param SCRIPT_FILENAME $document_root/vbseo.php; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root/vbseo.php; include fastcgi_params; }
Thanks for this! I tried this, and it kept breaking, but when I removed everything starting with the "location ~ \.php$ {" to the end everything started working correctly. When I tried loading it with it I was getting a message in shell about fastcgi not being able to open.
So... without that last part everything appears to work properly, so was it really necessary? Or will I run into problems later?
That is the php block, you would only have one php block in each nginx site config, so you must have doubled up by just coping the rules I already had.
Removing one is fine.
Excellent. Thanks for the help!