Page 1 of 2

moving to Nginx server

Posted: Sat Jan 28, 2012 12:08 pm
by keithstevens
Has anyone got the latest version of s9y working with nginx? I transfered an s9y site to a different server running debian linux, nginx and php5-fpm and upgraded the site to the latest version of s9y. The content is there at least partially but most links give a not found error. Found several different rewrite rule lists for s9y googling and tried them all but none of them worked, I think they were all pretty old. I tried converting the apache mod rewrite rules it generated in .htaccess but I get a too many arguments to the rewrite error from nginx so I've got something crooked. So finally to the question, does anyone have an example nginx config for the latest s9y?

Re: moving to Nginx server

Posted: Sat Jan 28, 2012 12:26 pm
by Timbalu

Re: moving to Nginx server

Posted: Sat Jan 28, 2012 3:23 pm
by keithstevens
Already tried that one. It didn't work. Its from 2008 so its possible the rewrite rules changed since?
thanks,
Keith

Re: moving to Nginx server

Posted: Sat Jan 28, 2012 3:32 pm
by Timbalu
No, I don't think they have changed since then... we had a change regarding special hosting (1&1) Servers, I remember.

Re: moving to Nginx server

Posted: Sat Jan 28, 2012 5:18 pm
by keithstevens
Not to argue, but it looks like they have changed because
A. They don't work, and
B. For example, here's the nginx rule from the article you referenced for the archives location:

rewrite ^/archives([/A-Za-z0-9]+)\.html /index.php?url=/archives/$1.html;

and here's the apache rule the installer of the latest version wrote in .htaccess for the archives location:

RewriteRule ^((archives/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+\.html)/?) index.php?/$1 [NC,L,QSA]

Notice the "url=" in the old one that isn't in the new one?

Re: moving to Nginx server

Posted: Sat Jan 28, 2012 6:07 pm
by Timbalu
True, that looks different, but I am not sure if it wasnt the Megg User...
keithstevens wrote:RewriteRule ^((archives/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+\.html)/?) index.php?/$1 [NC,L,QSA]
did you try to translate it to something like this?

Code: Select all

rewrite ^((archives/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+\.html)/?)$    /index.php?arg=$1   last;
Well, I am just guesing, having no experience with nginx...

Re: moving to Nginx server

Posted: Sat Jan 28, 2012 8:21 pm
by keithstevens
Yes, and it says:
Testing nginx configuration: [emerg]: invalid number of arguments in "rewrite" directive in /etc/nginx/sites-enabled/100-xyzabc.com.vhost

Re: moving to Nginx server

Posted: Sat Jan 28, 2012 9:16 pm
by keithstevens
It was just the ";" needed to be escaped, so now I have rules that pass nginx test but the page loads scrambled and links return not found errors so something is still wrong. Here's my nginx rules translated from the generated apache .htaccess file:
rewrite ^serendipity_admin.php$ serendipity_admin.php last;
rewrite ^((archives/([0-9]+)\-[0-9a-z\.\_!\;,\+\-\%]+\.html)/?)$ index.php?/$1 last;
rewrite ^(authors/([0-9]+)\-[0-9a-z\.\_!\;,\+\-\%]+)$ index.php?/$1 last;
rewrite ^(feeds/categories/([0-9\;]+)\-[0-9a-z\.\_!\;,\+\-\%]+\.rss)$ index.php?/$1 last;
rewrite ^(feeds/authors/([0-9]+)\-[0-9a-z\.\_!\;,\+\-\%]+\.rss)$ index.php?/$1 last;
rewrite ^(categories/([0-9\;]+)\-[0-9a-z\.\_!\;,\+\-\%]+)$ index.php?/$1 last;
rewrite ^archives([/A-Za-z0-9]+)\.html$ index.php?url=/archives/$1.html last;
rewrite ^([0-9]+)[_\-][0-9a-z_\-]*\.html$ index.php?url=$1-article.html last;
rewrite ^feeds/(.*)$ index.php?url=/feeds/$1 last;
rewrite ^unsubscribe/(.*)/([0-9]+)$ index.php?url=/unsubscribe/$1/$2 last;
rewrite ^approve/(.*)/(.*)/([0-9]+)$ index.php?url=approve/$1/$2/$3 last;
rewrite ^delete/(.*)/(.*)/([0-9]+)$ index.php?url=delete/$1/$2/$3 last;
rewrite ^(admin|entries)(/.+)?$ index.php?url=admin/ last;
rewrite ^archive/?$ index.php?url=/archive last;
rewrite ^(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$ rss.php?file=$1&ext=$2 last;
rewrite ^(plugin|plugin)/(.*)$ index.php?url=$1/$2 last;
rewrite ^search/(.*)$ index.php?url=/search/$1 last;
rewrite ^comments/(.*)$ index.php?url=/comments/$1 last;
rewrite ^(serendipity\.css|serendipity_admin\.css)$ index.php?url=/$1 last;
rewrite ^index\.(html?|php.+)$ index.php?url=index.html last;
rewrite ^htmlarea/(.*)$ htmlarea/$1 last;
rewrite (.*\.html?) index.php?url=/$1 last;

Re: moving to Nginx server

Posted: Sat Jan 28, 2012 10:08 pm
by keithstevens
It seems the browser is not able to read serendipity.css from the new site and I can't find serendipity.css only serendipity.css.php - Do I need to add some other special rule to nginx config for it?

Re: moving to Nginx server

Posted: Sat Jan 28, 2012 11:23 pm
by keithstevens
I got the serendipity.css to load by adding:

location /serendipity.css {
rewrite serendipity.css http://xyzabc.com/serendipity.css.php permanent;
}

to the nginx config and page renders correctly now but the links don't work so the rewrite rules are not working. I think probably the /serendipity.css location would not be needed if the nginx rewrite rules worked properly.

Re: moving to Nginx server

Posted: Sat Jan 28, 2012 11:54 pm
by keithstevens
The commented rewrite below works and the page renders correctly but the rule taken from the apache config does not work. To add to the confusion, browsing "http://xyzabc.com/index.php?url=/serendipity.css" returns the contents of the css file. I don't get it.

location /serendipity.css {
rewrite ^(serendipity\.css|serendipity_admin\.css) index.php?url=/$1 last;
# rewrite serendipity.css http://xyzabc.com/serendipity.css.php permanent;
}

Re: moving to Nginx server

Posted: Sun Jan 29, 2012 12:21 am
by garvinhicking
Hi Keith!

Thanks for your work here and documenting progress. I'm not sure I understand; you mean that /serendipity.css does not get rewritten in your current version? What's the actual URL so that I could see things actually (not) working?

Regards,
Garvin

Re: moving to Nginx server

Posted: Sun Jan 29, 2012 12:53 am
by keithstevens
Garvin,
Its not in DNS yet because the site I'm migrating from on apache is live. I have the target nginx servers IP address in my hosts file like this:
216.105.128.116 dodgecountynews.com

Re: moving to Nginx server

Posted: Sun Jan 29, 2012 12:57 am
by garvinhicking
Hi!

OK, patched by hosts file as well - but the serendipity.css does pull up for me properly?!

(The template output says s9y 1.6 is used, so it should be the right server?)

Re: moving to Nginx server

Posted: Sun Jan 29, 2012 1:10 am
by keithstevens
Garvin,
I'm going to have to take a break then because I'm not getting it here in either chrome or IE. I'll see what I can figure out and get back. In the mean time would it help to see the nginx config so far?