Hi!
Sadly I have never setup an nginx server on my own, so what I could/would test would be to analyze HTTP requests and see what comes up with different rewritten and non-rewritten URLs to see which pattern does not get properly rewritten, and if the "original" properly serves up...
I'm now going to bed (2 am german time) so take your time
Regards,
Garvin
moving to Nginx server
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: moving to Nginx server
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
- Regular
- Posts: 15
- Joined: Thu Feb 25, 2010 8:23 pm
Re: moving to Nginx server
Garvin,
OK, I figured out why you were able to dl the serendipity.css and wasn't. I actually have both "dodgecountynews.com" and "www.dodgecountynews.com" in my hosts file pointed to the same IP address. So when you tested, you loaded the index.php from the nginx server and that source said to get http://www.dodgecountynews.com/serendipity.css which pulled it off the old server for you. Back to the problem which is why the uncommented rewrite rule:
location ~ (serendipity\.css|serendipity_admin\.css)$ {
rewrite ^(serendipity\.css|serendipity_admin\.css)$ index.php?url=/$1 last;
# rewrite serendipity.css http://dodgecountynews.com/serendipity.css.php permanent;
}
does not work (with or without the $ terminator) and the commented one does work. I'll try to figure out...
-Keith
OK, I figured out why you were able to dl the serendipity.css and wasn't. I actually have both "dodgecountynews.com" and "www.dodgecountynews.com" in my hosts file pointed to the same IP address. So when you tested, you loaded the index.php from the nginx server and that source said to get http://www.dodgecountynews.com/serendipity.css which pulled it off the old server for you. Back to the problem which is why the uncommented rewrite rule:
location ~ (serendipity\.css|serendipity_admin\.css)$ {
rewrite ^(serendipity\.css|serendipity_admin\.css)$ index.php?url=/$1 last;
# rewrite serendipity.css http://dodgecountynews.com/serendipity.css.php permanent;
}
does not work (with or without the $ terminator) and the commented one does work. I'll try to figure out...
-Keith
-
- Regular
- Posts: 15
- Joined: Thu Feb 25, 2010 8:23 pm
Re: moving to Nginx server
I have not done extensive testing, but these nginx rules seem to work for me so far.
There were a few changes I had to make.
1. The regex likes a leading "/" following the ^
2. The replacement needs to (in general) start with a leading "/"
3. Since some of the captures now contain a leading "/" the extra "/"s in the replacements needed to be removed
4. It might just be this particular site, but I needed to add an uppercase (A-Z) range in a couple places so I just did it everywhere.
That's about it. Here are the rewrite rules that work for s9y 1.6 running on nginx 0.7.67-3
rewrite ^/serendipity_admin.php$ /serendipity_admin.php last;
rewrite ^((/archives/([0-9]+)\-[0-9a-zA-Z\.\_!\;,\+\-\%]+\.html)/?)$ /index.php?$1 last;
rewrite ^(/authors/([0-9]+)\-[0-9a-zA-Z\.\_!\;,\+\-\%]+)$ /index.php?$1 last;
rewrite ^(/feeds/categories/([0-9\;]+)\-[0-9a-zA-Z\.\_!\;,\+\-\%]+\.rss)$ /index.php?$1 last;
rewrite ^(/feeds/authors/([0-9]+)\-[0-9a-zA-Z\.\_!\;,\+\-\%]+\.rss)$ /index.php?$1 last;
rewrite ^(/categories/([0-9]+)\-[0-9a-zA-Z\.\_!\;,\+\-\%]+)$ /index.php?$1 last;
rewrite ^/archives([/A-Za-z0-9]+)\.html$ /index.php?url=/archives/$1.html last;
rewrite ^/([0-9]+)[_\-][0-9a-zA-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;
There were a few changes I had to make.
1. The regex likes a leading "/" following the ^
2. The replacement needs to (in general) start with a leading "/"
3. Since some of the captures now contain a leading "/" the extra "/"s in the replacements needed to be removed
4. It might just be this particular site, but I needed to add an uppercase (A-Z) range in a couple places so I just did it everywhere.
That's about it. Here are the rewrite rules that work for s9y 1.6 running on nginx 0.7.67-3
rewrite ^/serendipity_admin.php$ /serendipity_admin.php last;
rewrite ^((/archives/([0-9]+)\-[0-9a-zA-Z\.\_!\;,\+\-\%]+\.html)/?)$ /index.php?$1 last;
rewrite ^(/authors/([0-9]+)\-[0-9a-zA-Z\.\_!\;,\+\-\%]+)$ /index.php?$1 last;
rewrite ^(/feeds/categories/([0-9\;]+)\-[0-9a-zA-Z\.\_!\;,\+\-\%]+\.rss)$ /index.php?$1 last;
rewrite ^(/feeds/authors/([0-9]+)\-[0-9a-zA-Z\.\_!\;,\+\-\%]+\.rss)$ /index.php?$1 last;
rewrite ^(/categories/([0-9]+)\-[0-9a-zA-Z\.\_!\;,\+\-\%]+)$ /index.php?$1 last;
rewrite ^/archives([/A-Za-z0-9]+)\.html$ /index.php?url=/archives/$1.html last;
rewrite ^/([0-9]+)[_\-][0-9a-zA-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
Hi!
My blog is running on nginx.
I have not the access to the rootserver, because I am guest with my blog on the server of a fellow.
If you are interested in a comparison ask me for a dump. I will try to get one again.
Soon I want to move my blog to a hoster, maybe Manitu, because they are recomended. Maybe they help me with the installation. I want to ask their before I book.
greetings
Jörg
My blog is running on nginx.
I have not the access to the rootserver, because I am guest with my blog on the server of a fellow.
If you are interested in a comparison ask me for a dump. I will try to get one again.
Soon I want to move my blog to a hoster, maybe Manitu, because they are recomended. Maybe they help me with the installation. I want to ask their before I book.
greetings
Jörg
Re: moving to Nginx server
I run into the same issues with an installation of serendipity on nginx. I got some 404 Errors.
The Relative HTTP Path was not correctly set while installation (conf was set to /serendipity_admin.php/).
I have used the following nginx rewrite rule, for a workaround
This rewrites all content after /serendipity_admin.php to /. Now i was able to use the system correctly and reconfigure the Relative HTTP Path in the Administration Configuration.
Note: Delete the before used rewrite rule, after fixing the path.
And for the rest of the rewrite configuration, simple used this config:
Maybe this helps some users to migrate to nginx.
The Relative HTTP Path was not correctly set while installation (conf was set to /serendipity_admin.php/).
I have used the following nginx rewrite rule, for a workaround
Code: Select all
rewrite ^/serendipity_admin.php/(.*)$ /$1 last;
This rewrites all content after /serendipity_admin.php to /. Now i was able to use the system correctly and reconfigure the Relative HTTP Path in the Administration Configuration.
Note: Delete the before used rewrite rule, after fixing the path.
And for the rest of the rewrite configuration, simple used this config:
Code: Select all
location / {
index index.php;
# serve static files that exist without running other rewrite tests
if (-f $request_filename) {
expires 30d;
break;
}
# send all non-existing file or directory requests to index.php
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?$1 last;
}
}