2009年12月31日星期四

Re: var/www

Hi Paul,
> A quick side question - do you know whether I can run nginx as well as
> apache2 on the server? nginx would handle all ports except eBox
> administration. Just a thought - not important really, but I am not sure
> whether eBox needs apache2.
You can have apache listen on a separate port then apache2 and either access apache directly via the alternate port or you can have nginx proxy to the apache port so you can use standard access.

> The web server will have two domains to host from the same fixed IP, and
> needs SSL for one of them.
You can have multiple servers on 1 ip address easily. http://wiki.nginx.org/NginxHttpCoreModule#server there are limitations with SSL and ip addresses SNI http://en.wikipedia.org/wiki/Server_Name_Indication is needed if you want multiple hosts with SSL.

> The trial computer now has all apache2 files taken off, and nginx is now
> the web server. One of the web sites will be a rails site.
>
> The rails site on the trial computer is at /home/paul/sites/my_app/, and
> has all the usual sub-directories created by rails. I don't know where
> to put the rails files on the web server at present.
You can put them anywhere you want on the server as long as you point it to the location of your rails app.
I personally use a structure like
/var/www/domain.com/ to hold the website. and then just put the roots to the proper location. if its a standard website i normally create a htdocs folder for all the web files. If its rails app i just use the rails structure and put everything in public etc etc.

>
> There seem to be 4 files with configuration for gninx it them:
>
> /var/nginx/conf/nginx.conf (this one I changed - probably the wrong
> one!)
> /etc/nginx/nginx.conf (no changed made since installation)
> /etc/nginx/sites-available/default (no changed made since installation)
> /etc/nginx/sites-enabled/default (no changed made since installation)
Using Debain 5.0 the config files are /etc/nginx/nginx.conf and probably the sites-availabe and sites-enabled ones. I am sure Ubuntu has the same structure.

> (virtual host, ssl and php are # out at present - I take it that is
> default)
http://wiki.nginx.org is good resource for finding example configuration files and all the modules.

V/r,
Rob Schultz
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: page generation time and actual response time difference

firebug is affected by firefox's speed, the client machine's speed and the speed of your network. on a page I just tested on my site, firebug says 10-100ms per request just in "waiting for response" while ab (Apache Bench) says it takes at most 19ms total (not just waiting for response) per request under load (i.e., when doing 4000 requests with a concurrency of 40). curl says it takes 3-10ms total (not just waiting for response). I'm running ab and curl on the same machine with Firefox.

remove components until you find the slow piece. what does ab or curl (using -w and time_pretransfer) say? how fast is it if you run ab or curl on the nginx server itself rather than across the network? what does firebug or curl say about a known fast site like www.google.com? I get about 100ms in Firebug's "waiting for response" against google.com but curl ranges from 3-45ms.

and how big (in bytes) is your home page? does it change significantly for smaller pages?

Firebug is very erratic too, if I hit refresh several times it can increase by a factor of 10. I wouldn't put too much weight on what Firebug says. I don't know anything about Pingdom.


On Dec 31, 2009, at 7:35 AM, Ehud Rosenberg wrote:

> Hi all,
> I'm seeing something a bit odd in our rails app. In the application log
> file I see the homepage is constantly generated in under 350ms,
> sometimes going as far down as 150ms. However, when I run firebug
> locally or Pingdom to test how long it takes to load our site, it
> constantly shows a much larger "waiting for response" time, usually
> around 600-700ms. I was wondering if anyone can help me figure out the
> large difference? Where are those 300-400ms spent?
> Is it possibly related to nginx configuration?
> The server is an 8cpu, 8gb ubuntu installation with a server load of
> about 1.6.
> Thanks!
> --
> Posted via http://www.ruby-forum.com/.
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: Possible bug in SSI include handling

This bug has existed for a long time since nginx 0.6×. Sockets are closed incorrectly when ssi sub-requests finished.

The workaround is to set 'wait' attribute to be true which make sub-requests go to back end one by one.


On Thu, Dec 31, 2009 at 10:58 PM, Maxim Dounin <mdounin@mdounin.ru> wrote:
Hello!

On Wed, Dec 30, 2009 at 02:42:16PM -0500, Maxim Khitrov wrote:

> This file structure required to duplicate this bug is a bit complex to
> explain. Therefore, I put the required files into a tiny archive,
> which you can download from [1].

[...]

> I started looking through the source code for ssi module, but I'm
> hoping that someone more familiar with nginx internals would be able
> to find a solution quicker. It seems that adding wait="yes" to the
> virtual include in bad.html also fixes the problem, so I suspect that
> the issue is with requests being performed in parallel.

I'm able to reproduce it here, thanks.  I'll take a look (but most
likely after New Year).

It seems to be caused by mix of waited (include file=... is
implicitly waited) and non-waited subrequests with non-trivial
nesting.

BTW, Happy New Year!

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx



--
要了几天饱饭就不记得西北风啥味了

Re: ngx_drizzle: make nginx talk directly to mysql, drizzle, and sqlite3 by libdrizzle

Looks great! Thanks for sharing!

Happy New Year!

Best regards,
Piotr Sikora < piotr.sikora@frickle.com >


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: bug in autoindex module

Hello!

On Thu, Dec 31, 2009 at 09:51:31AM -0500, Ross wrote:

> On Thu, Dec 31, 2009 at 9:16 AM, Maxim Dounin <mdounin@mdounin.ru> wrote:
> > Hello!
> >
> > On Thu, Dec 31, 2009 at 02:05:04AM +0300, Maxim Dounin wrote:
> >
> >> On Wed, Dec 30, 2009 at 01:16:42PM -0500, Ross wrote:
> >
> > [...]
> >
> >> > I wonder if this is related to a bug in which the autoindex module
> >> > occasionally truncates non-ASCII filenames.
> >> >
> >> > Examples of the bug can be found at http://thegodlikehobo.org/tmp/
> >> > Each file contains its own name. The 4th (Списки), 7th (テスト), and 8th
> >> > (フロリダ) files from the top have had their name truncated, but the link
> >> > is correct.
> >>
> >> No, it's unrelated problem. I'm able to reproduce it here, I'll
> >> take a look.
> >
> > Patch.
>
> Thank you, the patch works great with 0.7.64!
>
> However, now I notice a different issue with the autoindex. At the
> same location (http://thegodlikehobo.org/tmp/) the date and size
> columns of the English and Russian filenames are aligned, but the
> Japanese ones seem to be random. I see the misalignment in Firefox,
> Chrome, and Opera.

nginx uses fixed-width font in autoindex, and this is
fullwidth/halfwidth problem I'm not really want to dig into. And,
given the fact that different browsers misalign the above page
differently, it won't help anyway.

I believe instead autoindex should be reworked to be able to
produce XML and hence allow any layout via XSLT. This will
resolve the above issue by providing means to use layouts with
proportional fonts.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

page generation time and actual response time difference

Hi all,
I'm seeing something a bit odd in our rails app. In the application log
file I see the homepage is constantly generated in under 350ms,
sometimes going as far down as 150ms. However, when I run firebug
locally or Pingdom to test how long it takes to load our site, it
constantly shows a much larger "waiting for response" time, usually
around 600-700ms. I was wondering if anyone can help me figure out the
large difference? Where are those 300-400ms spent?
Is it possibly related to nginx configuration?
The server is an 8cpu, 8gb ubuntu installation with a server load of
about 1.6.
Thanks!
--
Posted via http://www.ruby-forum.com/.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: Possible bug in SSI include handling

Hello!

On Wed, Dec 30, 2009 at 02:42:16PM -0500, Maxim Khitrov wrote:

> This file structure required to duplicate this bug is a bit complex to
> explain. Therefore, I put the required files into a tiny archive,
> which you can download from [1].

[...]

> I started looking through the source code for ssi module, but I'm
> hoping that someone more familiar with nginx internals would be able
> to find a solution quicker. It seems that adding wait="yes" to the
> virtual include in bad.html also fixes the problem, so I suspect that
> the issue is with requests being performed in parallel.

I'm able to reproduce it here, thanks. I'll take a look (but most
likely after New Year).

It seems to be caused by mix of waited (include file=... is
implicitly waited) and non-waited subrequests with non-trivial
nesting.

BTW, Happy New Year!

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: bug in autoindex module

On Thu, Dec 31, 2009 at 9:16 AM, Maxim Dounin <mdounin@mdounin.ru> wrote:
> Hello!
>
> On Thu, Dec 31, 2009 at 02:05:04AM +0300, Maxim Dounin wrote:
>
>> On Wed, Dec 30, 2009 at 01:16:42PM -0500, Ross wrote:
>
> [...]
>
>> > I wonder if this is related to a bug in which the autoindex module
>> > occasionally truncates non-ASCII filenames.
>> >
>> > Examples of the bug can be found at http://thegodlikehobo.org/tmp/
>> > Each file contains its own name. The 4th (Списки), 7th (テスト), and 8th
>> > (フロリダ) files from the top have had their name truncated, but the link
>> > is correct.
>>
>> No, it's unrelated problem. I'm able to reproduce it here, I'll
>> take a look.
>
> Patch.
>
> Maxim Dounin
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>
>

Thank you, the patch works great with 0.7.64!

However, now I notice a different issue with the autoindex. At the
same location (http://thegodlikehobo.org/tmp/) the date and size
columns of the English and Russian filenames are aligned, but the
Japanese ones seem to be random. I see the misalignment in Firefox,
Chrome, and Opera.

-Ross

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: bug in autoindex module

# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1262224940 -10800
# Node ID e06f16583f28f61683e123360902b934fdb8f929
# Parent 1373d689c4b2d03c83f811781427960143345f83
Autoindex: fix utf-8 handling.

diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -1239,10 +1239,8 @@ ngx_utf8_cpystrn(u_char *dst, u_char *sr
break;
}

- len--;
-
while (src < next) {
- *++dst = *++src;
+ *dst++ = *src++;
len--;
}
}
Hello!

On Thu, Dec 31, 2009 at 02:05:04AM +0300, Maxim Dounin wrote:

> On Wed, Dec 30, 2009 at 01:16:42PM -0500, Ross wrote:

[...]

> > I wonder if this is related to a bug in which the autoindex module
> > occasionally truncates non-ASCII filenames.
> >
> > Examples of the bug can be found at http://thegodlikehobo.org/tmp/
> > Each file contains its own name. The 4th (Списки), 7th (テスト), and 8th
> > (フロリダ) files from the top have had their name truncated, but the link
> > is correct.
>
> No, it's unrelated problem. I'm able to reproduce it here, I'll
> take a look.

Patch.

Maxim Dounin

Re: bug in autoindex module

# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1262268599 -10800
# Node ID 5ad805f474d01becd42f1aa6ae9d802ce30bf9de
# Parent e06f16583f28f61683e123360902b934fdb8f929
Autoindex: escape html in file names.

diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -26,6 +26,7 @@ typedef struct {
ngx_str_t name;
size_t utf_len;
size_t escape;
+ size_t escape_html;

unsigned dir:1;
unsigned colon:1;
@@ -138,7 +139,7 @@ ngx_http_autoindex_handler(ngx_http_requ
{
u_char *last, *filename, scale;
off_t length;
- size_t len, utf_len, allocated, root;
+ size_t len, char_len, escape_html, allocated, root;
ngx_tm_t tm;
ngx_err_t err;
ngx_buf_t *b;
@@ -345,6 +346,9 @@ ngx_http_autoindex_handler(ngx_http_requ
entry->escape = 2 * ngx_escape_uri(NULL, ngx_de_name(&dir), len,
NGX_ESCAPE_HTML);

+ entry->escape_html = ngx_escape_html(NULL, entry->name.data,
+ entry->name.len);
+
if (utf8) {
entry->utf_len = ngx_utf8_length(entry->name.data, entry->name.len);
} else {
@@ -363,10 +367,12 @@ ngx_http_autoindex_handler(ngx_http_requ
ngx_close_dir_n " \"%s\" failed", &path);
}

+ escape_html = ngx_escape_html(NULL, r->uri.data, r->uri.len);
+
len = sizeof(title) - 1
- + r->uri.len
+ + r->uri.len + escape_html
+ sizeof(header) - 1
- + r->uri.len
+ + r->uri.len + escape_html
+ sizeof("</h1>") - 1
+ sizeof("<hr><pre><a href=\"../\">../</a>" CRLF) - 1
+ sizeof("</pre><hr>") - 1
@@ -379,6 +385,7 @@ ngx_http_autoindex_handler(ngx_http_requ
+ 1 /* 1 is for "/" */
+ sizeof("\">") - 1
+ entry[i].name.len - entry[i].utf_len + entry[i].colon * 2
+ + entry[i].escape_html
+ NGX_HTTP_AUTOINDEX_NAME_LEN + sizeof("&gt;") - 2
+ sizeof("</a>") - 1
+ sizeof(" 28-Sep-1970 12:00 ") - 1
@@ -398,9 +405,18 @@ ngx_http_autoindex_handler(ngx_http_requ
}

b->last = ngx_cpymem(b->last, title, sizeof(title) - 1);
- b->last = ngx_cpymem(b->last, r->uri.data, r->uri.len);
- b->last = ngx_cpymem(b->last, header, sizeof(header) - 1);
- b->last = ngx_cpymem(b->last, r->uri.data, r->uri.len);
+
+ if (escape_html) {
+ b->last = (u_char *) ngx_escape_html(b->last, r->uri.data, r->uri.len);
+ b->last = ngx_cpymem(b->last, header, sizeof(header) - 1);
+ b->last = (u_char *) ngx_escape_html(b->last, r->uri.data, r->uri.len);
+
+ } else {
+ b->last = ngx_cpymem(b->last, r->uri.data, r->uri.len);
+ b->last = ngx_cpymem(b->last, header, sizeof(header) - 1);
+ b->last = ngx_cpymem(b->last, r->uri.data, r->uri.len);
+ }
+
b->last = ngx_cpymem(b->last, "</h1>", sizeof("</h1>") - 1);

b->last = ngx_cpymem(b->last, "<hr><pre><a href=\"../\">../</a>" CRLF,
@@ -438,20 +454,41 @@ ngx_http_autoindex_handler(ngx_http_requ

if (entry[i].name.len != len) {
if (len > NGX_HTTP_AUTOINDEX_NAME_LEN) {
- utf_len = NGX_HTTP_AUTOINDEX_NAME_LEN - 3 + 1;
+ char_len = NGX_HTTP_AUTOINDEX_NAME_LEN - 3 + 1;

} else {
- utf_len = NGX_HTTP_AUTOINDEX_NAME_LEN + 1;
+ char_len = NGX_HTTP_AUTOINDEX_NAME_LEN + 1;
}

+ last = b->last;
b->last = ngx_utf8_cpystrn(b->last, entry[i].name.data,
- utf_len, entry[i].name.len + 1);
+ char_len, entry[i].name.len + 1);
+
+ if (entry[i].escape_html) {
+ b->last = (u_char *) ngx_escape_html(last, entry[i].name.data,
+ b->last - last);
+ }
+
last = b->last;

} else {
- b->last = ngx_cpystrn(b->last, entry[i].name.data,
- NGX_HTTP_AUTOINDEX_NAME_LEN + 1);
- last = b->last - 3;
+ if (entry[i].escape_html) {
+ if (len > NGX_HTTP_AUTOINDEX_NAME_LEN) {
+ char_len = NGX_HTTP_AUTOINDEX_NAME_LEN - 3;
+
+ } else {
+ char_len = len;
+ }
+
+ b->last = (u_char *) ngx_escape_html(b->last,
+ entry[i].name.data, char_len);
+ last = b->last;
+
+ } else {
+ b->last = ngx_cpystrn(b->last, entry[i].name.data,
+ NGX_HTTP_AUTOINDEX_NAME_LEN + 1);
+ last = b->last - 3;
+ }
}

if (len > NGX_HTTP_AUTOINDEX_NAME_LEN) {
Hello!

On Thu, Dec 31, 2009 at 01:55:31AM +0300, Maxim Dounin wrote:

> Hello!
>
> On Thu, Dec 31, 2009 at 12:45:18AM +0700, Edho P Arief wrote:
>
> > On Tue, Dec 29, 2009 at 5:20 PM, Edho P Arief <edhoprima@gmail.com> wrote:
> > > Don't know if found by someone else, but I find this bug today in
> > > autoindex module.
> > >
> > > Basically, the file/dirname is not escaped properly.
> > >
> > > To reproduce:
> > > - enable autoindex in a directory
> > > - create file with name "some<em>thing" in the directory
> > > - view the (broken) directory list in web
> > >
> >
> > it should use ngx_escape_html - I've tried modifying it but I don't
> > know enough C to correctly fix it.
>
> I'm currently looking in it, stay tuned.

Patch.

Maxim Dounin

ngx_drizzle: make nginx talk directly to mysql, drizzle, and sqlite3 by libdrizzle

Hi, guys!

This is the last day in 2009 and I'm too impatient to hold the first
release (version v0.0.1) of our ngx_drizzle module, an upstream module
that talks directly to RDBMS backends like mysql, drizzle, and the
drizzle server shipped with libdrizzle for sqlite3.

This module is initially started by my friend and colleague,
chaoslawful. His Chinese name is 王晓哲 :) He did the initial (most
difficult) work all in his own time :) I also shamelessly borrowed a
lot of code from Igor's ngx_http_upstream.c and
ngx_http_memcached_module.c in the nginx 0.8.30 core, as well as Maxim
Dounin's excellent upstream_keepalive module. These parts of code are
copyrighted by these authors, respectively.

This module is still at its very early phase of development and
considered highly experimental. But you're encouraged to test it out
on your side and report any quirks that you experience :)

Here's some sample configurations:

http {
...

upstream cluster {
# simple round-robin
drizzle_server 127.0.0.1:3306 dbname=test
password=some_pass user=monty protocol=mysql;
drizzle_server 127.0.0.1:1234 dbname=test2
password=pass user=bob protocol=drizzle;
}

upstream backend {
drizzle_server 127.0.0.1:3306 dbname=test
password=some_pass user=monty protocol=mysql;
}

server {
location /mysql {
set $my_sql 'select * from cats';
drizzle_query $my_sql;

drizzle_pass backend;
}
...
}
}

Essentially it provides a very efficient and flexible way for nginx
internals to access mysql, drizzle, sqlite3, as well as other RDBMS's
that support the drizzle protocol or mysql protocol. Also it can serve
as a direct REST interface to those RDBMS backends.

It also has a builtin per-worker connection pool mechanism borrowed
from Maxim Dounin's upstream_keepalive module.

Here's a sample configuration:

upstream backend {
drizzle_server 127.0.0.1:3306 dbname=test
password=some_pass user=monty protocol=mysql;
drizzle_keepalive max=100 mode=single overflow=reject;
}

You may wonder why it will be useful for your PHP/Python/Perl/Java
applications fastcgi'd or proxied by nginx. Well, we'll work out an
ngx_accel_subrequest module some time in the future to allow these
backend apps directly issue subrequests by means of the special
X-Accel-Subrequest header and continuation passing style.

Unlike the current X-Accel-Redirect trick we're already familiar with,
X-Accel-Subrequest is more like a function invocation that issues one
(or multiple parallel subrequests), and eventually *returns* back when
the resulting data the subrequest obtains is ready and gives control
back to your backend apps to go on processing the data.

Sadly this mdoule does not have a wiki page yet, just the source
repository on GitHub:

http://github.com/chaoslawful/drizzle-nginx-module

I've done some work in the README file there. I promise I'll work on
the wiki doc in another day ;)

Release tarballs can be downloaded from the page below

http://github.com/chaoslawful/drizzle-nginx-module/downloads

I've also cc'd the nginx-devel mailing list in hope to get interested
developers to join this project's development. __YOU__ are always
welcomed!

Happily, we've already got a working framework for integrating
third-party libraries like libdrizzle and libpq into nginx's upstream
system as long as the libraries meet the following prerequisites:

1. It exposes the underlying socket fd.
2. It has a truly non-blocking API for its operations.

libdrizzle and libpq meet these conditions while oracle's OCI library
needs some hack for the requirement #1. So, you can expect ngx_oracle
and even ngx_pgsql to be announced here in the next few weeks or so,
and you'll see even more! If you'd join the fun, please don't hesitate
to drop us a line :)

Happy new year!

Enjoy!
-agentzh

P.S. I was hoping to release v0.0.1 by this Christmas, but missed the
deadline because I had spent too much time on fixing weird bugs in the
ngx_chunkin module :P

The year 2009 is my first year in the nginx community. Thank you all
for creating such a live community and thanks Igor for creating nginx
in the first place ;) I'm going to do more nginx C hacking in the next
year! :D

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

2009年12月30日星期三

Re: AIO cause memory leak

Thanks!

On 12/30/2009 11:17 PM, Igor Sysoev wrote:
> On Wed, Dec 30, 2009 at 04:09:59PM +0800, Tony wrote:
>
>
>> I got the memory leak error on my linux server when I added 'aio on;' in
>> my nginx.conf,
>> The os is fedora 11(x86-64) and gentoo(x86-64),The kernel is 2.6.29+.
>> I've already set 'directio 2m; sendfile on; ' into nginx.conf.
>> The server is only serving static flv contents, These is 50-100MBytes
>> each flv file.
>>
>> When 'aio on' is setting, the server's 4G memory and 2G swap were
>> consumed by nginx, work_processes just 4.
>> When I disable aio, each nginx processes used 30M memory only.
>>
>> When aio is used, I know it should disable sendfile and use directio,
>> Why it use so many memory?
>>
> It's a known bug. I will fix it in January.
>
>
>


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: bug in autoindex module

Hello!

On Wed, Dec 30, 2009 at 01:16:42PM -0500, Ross wrote:

> On Tue, Dec 29, 2009 at 5:20 AM, Edho P Arief <edhoprima@gmail.com> wrote:
> > Don't know if found by someone else, but I find this bug today in
> > autoindex module.
> >
> > Basically, the file/dirname is not escaped properly.
> >
> > To reproduce:
> > - enable autoindex in a directory
> > - create file with name "some<em>thing" in the directory
> > - view the (broken) directory list in web
> >
> > --
> > O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
> >
> > _______________________________________________
> > nginx mailing list
> > nginx@nginx.org
> > http://nginx.org/mailman/listinfo/nginx
> >
>
> I wonder if this is related to a bug in which the autoindex module
> occasionally truncates non-ASCII filenames.
>
> Examples of the bug can be found at http://thegodlikehobo.org/tmp/
> Each file contains its own name. The 4th (Списки), 7th (テスト), and 8th
> (フロリダ) files from the top have had their name truncated, but the link
> is correct.

No, it's unrelated problem. I'm able to reproduce it here, I'll
take a look.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: bug in autoindex module

Hello!

On Thu, Dec 31, 2009 at 12:45:18AM +0700, Edho P Arief wrote:

> On Tue, Dec 29, 2009 at 5:20 PM, Edho P Arief <edhoprima@gmail.com> wrote:
> > Don't know if found by someone else, but I find this bug today in
> > autoindex module.
> >
> > Basically, the file/dirname is not escaped properly.
> >
> > To reproduce:
> > - enable autoindex in a directory
> > - create file with name "some<em>thing" in the directory
> > - view the (broken) directory list in web
> >
>
> it should use ngx_escape_html - I've tried modifying it but I don't
> know enough C to correctly fix it.

I'm currently looking in it, stay tuned.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Possible bug in SSI include handling

Hello all,

This file structure required to duplicate this bug is a bit complex to
explain. Therefore, I put the required files into a tiny archive,
which you can download from [1].

This problem is appearing in latest 0.7 and 0.8 releases on FreeBSD
7.2. Download the archive, extract it to some directory, and start
nginx with the included configuration file (edit the "root" directive
as needed first). If you then view /good1.html and /good2.html, you
should see the following text:

File Header
Page Header
Content
Sidebar
Page Footer
File Footer

Viewing bad.html will show this:

File Header
Page Header
Content
Sidebar

The last two lines are missing. If you look at the source for all
three files, you'll see where the problem is. Conceptually, they are
all identical, but something breaks when executing the SSI code in
bad.html. More precisely, execution seems to stop after the first
include directive in content_footer.inc. Files good1.html and
good2.html show two ways of fixing the problem, but I cannot find a
good explanation as to why the original file doesn't work as expected.

I started looking through the source code for ssi module, but I'm
hoping that someone more familiar with nginx internals would be able
to find a solution quicker. It seems that adding wait="yes" to the
virtual include in bad.html also fixes the problem, so I suspect that
the issue is with requests being performed in parallel.

- Max

[1] http://www.bhsai.org/downloads/ssi.tgz

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: Using NGINX as reverse proxy for OWA

On Tue, Dec 29, 2009 at 4:45 AM, Michael Nolte - Stadt Weener (Ems)
<nolte@weener.de> wrote:
> I got the same "Content Encoding" errors. I had to add the following to
> my config:
>
> proxy_set_header Accept-Encoding "";
>
> After that it works with my (german) SBS 2003...
>

I have seen this same issue when using nginx to proxy to other
applications (not OWA) on IIS6 (Windows Server 2003). But, it only
happened on servers that had HTTP compression enabled for dynamic
pages, AND the "HcNoCompressionForHttp10=false" set in the metabase.
With those two settings, IIS6 replies with chunked encoding even
though the HTTP requests from nginx are http 1.0. Nginx does not
expect this, since it made an HTTP/1.0 request. So nginx then blinmdly
applies its own chunking as well when sending the response back to the
browser, resulting in "double chunking" and the content encoding error
you've seen (IE8 just gives a "page cannot be displayed" error).

This is clearly a bug and RFC violation in IIS6, it should never
return chunked encoding to an HTTP/1.0 request. I posted a comment to
this effect on TechNet's page describing the HcNoCompressionForHttp10
metabase property, but Windows 2003 is exiting mainstream support
soon, so I would not expect a fix.

I suppose it is possible those two metabase values are set to false by
default in the metabase.xml for SBS 2003, but I know those settings
are TRUE by default on a "stock" install of windows server 2003 or
2003R2. The Small Business Server stack has a lot of strange defaults
in my opinion, but this one would really surprise me, as it would
break OWA for people using most proxies (Squid, etc.)

As you discovered, setting the Accept-Encoding header to the empty
string fixes the issue, since IIS no longer tries to compress the
dynamic content, and therefore does not use chunked encoding. This is
fine if your nginx and OWA boxes have good connectivity between them,
but if they are on separate sides of a WAN link, the loss of
compression between nginx and OWA can make it quite a bit slower.


--
RPM

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: bug in autoindex module

On Tue, Dec 29, 2009 at 5:20 AM, Edho P Arief <edhoprima@gmail.com> wrote:
> Don't know if found by someone else, but I find this bug today in
> autoindex module.
>
> Basically, the file/dirname is not escaped properly.
>
> To reproduce:
> - enable autoindex in a directory
> - create file with name "some<em>thing" in the directory
> - view the (broken) directory list in web
>
> --
> O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>

I wonder if this is related to a bug in which the autoindex module
occasionally truncates non-ASCII filenames.

Examples of the bug can be found at http://thegodlikehobo.org/tmp/
Each file contains its own name. The 4th (Списки), 7th (テスト), and 8th
(フロリダ) files from the top have had their name truncated, but the link
is correct.

-Ross

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: bug in autoindex module

On Tue, Dec 29, 2009 at 5:20 PM, Edho P Arief <edhoprima@gmail.com> wrote:
> Don't know if found by someone else, but I find this bug today in
> autoindex module.
>
> Basically, the file/dirname is not escaped properly.
>
> To reproduce:
> - enable autoindex in a directory
> - create file with name "some<em>thing" in the directory
> - view the (broken) directory list in web
>

it should use ngx_escape_html - I've tried modifying it but I don't
know enough C to correctly fix it.


--
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: AIO cause memory leak

On Wed, Dec 30, 2009 at 04:09:59PM +0800, Tony wrote:

> I got the memory leak error on my linux server when I added 'aio on;' in
> my nginx.conf,
> The os is fedora 11(x86-64) and gentoo(x86-64),The kernel is 2.6.29+.
> I've already set 'directio 2m; sendfile on; ' into nginx.conf.
> The server is only serving static flv contents, These is 50-100MBytes
> each flv file.
>
> When 'aio on' is setting, the server's 4G memory and 2G swap were
> consumed by nginx, work_processes just 4.
> When I disable aio, each nginx processes used 30M memory only.
>
> When aio is used, I know it should disable sendfile and use directio,
> Why it use so many memory?

It's a known bug. I will fix it in January.


--
Igor Sysoev
http://sysoev.ru/en/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: Directory fallback

Eureka!

Final version, accomplishing all my objectives:
- site dir, with fallback to base dir;
- static files directly, php files through fastcgi;
- not calling fastcgi on nonexistent files;
- not using "if" (somebody mentioned performance problems?)

location / {
root /var/www/site1;
try_files $uri @base;
}
location @base {
root /var/www/base;
}
location ~ \.php$ {
root /var/www/site1;
try_files $uri @basephp;
fastcgi_pass 127.0.0.1:9000;
}
location @basephp {
root /var/www/base;
try_files $uri ERROR;
fastcgi_pass 127.0.0.1:9000;
}

Is there anything nicer I can put in the last try_files, instead of the nonexistent file "ERROR"?

Tobia
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: RE: i've been trying to convert this .htaccess for a week now

-------- Original-Nachricht --------
> Datum: Tue, 29 Dec 2009 20:35:15 -0600
> Von: "AMP Admin" <admin@ampprod.com>
> An: nginx@nginx.org
> Betreff: RE: i\'ve been trying to convert this .htaccess for a week now

> Wow! This is awesome! I'll start working with this and see what I can
> come
> up with.
>
It would help if you could post the whole configuration you use for that software. I mean the nginx part. Then others could easier tell if a "last", "break" or "permanent" should be used in the rewrite conditions.

What web application is that what you use over there? I mean: What software needs those rewrite rules? Is it something open that can be downloaded from the web?


> Btw, I'm running Nginx 0.7.64
>
Thanks.


> -----Original Message-----
> From: Steve [mailto:steeeeeveee@gmx.net]
> Sent: Tuesday, December 29, 2009 7:53 PM
> To: nginx@nginx.org
> Subject: Re: i've been trying to convert this .htaccess for a week now
>
>
> -------- Original-Nachricht --------
> > Datum: Mon, 28 Dec 2009 20:24:14 -0600
> > Von: "AMP Admin" <admin@ampprod.com>
> > An: nginx@nginx.org
> > Betreff: i\'ve been trying to convert this .htaccess for a week now
>
> > I hate to ask but this one is just too big and complicated for me to
> > convert. Any help would be good. Thanks!
> >
> >
> >
> [removed long list of Apache Rewrite rules]
> >
> >
> Since I don't know where you need those rewrites and what version of nginx
> you are using and how you have setup the other stuff in nginx I am not
> able
> to optimize the rewrite rules (some stuff can be done without rewriting
> when
> using newer version of nginx). Anyway.... here a suggestion (you might
> need
> to change "permanent" to "last" or in some cases to "break" but all this
> depends where you add those rewrite rules in your nginx.conf):
> --------------------------
> rewrite ^/articles/?$ /articles.php permanent;
> rewrite ^/articles/([^/.]+)/?$
> /articles.php?action=viewarticle&articleUri=$1? permanent;
> rewrite ^/articles/category/([^/.]+)/?$
> /articles.php?action=viewcategory&articleCatUri=$1? permanent;
>
> rewrite ^/news/?$ /news.php permanent;
> rewrite ^/news/([^/.]+)/?$ /news.php?newsUri=$1? permanent;
>
> rewrite ^/blogs/?$ /blogs.php permanent;
> rewrite ^/blogs/all/(\d+)/(\d+)/?$ /blogs.php?page=$2&per_page=$1?
> permanent;
> rewrite ^/blogs/top/?$ /blogs.php?action=top_blogs? permanent;
> rewrite ^/blogs/top/(\d+)/(\d+)/?$
> /blogs.php?action=top_blogs&page=$2&per_page=$1? permanent;
> rewrite ^/blogs/top_posts/?$ /blogs.php?action=top_posts? permanent;
> rewrite ^/blogs/tag/([^/.]+)/?$
> /blogs.php?action=search_by_tag&tagKey=$1?
> permanent;
> rewrite ^/blogs/tag/?$ /blogs.php?action=search_by_tag&tagKey=?
> permanent;
> rewrite ^/blogs/posts/([^/.]+)/tag/([^/.]+)/?$
> /blogs.php?action=search_by_tag&tagKey=$2&ownerName=$1? permanent;
> rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/?$
> /blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2?
> permanent;
> rewrite ^/blogs/entry/([^/.]+)/?$
> /blogs.php?action=show_member_post&postUri=$1? permanent;
> rewrite ^/blogs/entry/?$ /blogs.php?action=show_member_post&postUri=?
> permanent;
> rewrite ^/blogs/posts/([^/.]+)/?$
> /blogs.php?action=show_member_blog&ownerName=$1? permanent;
> rewrite ^/blogs/posts/?$ /blogs.php?action=show_member_blog&ownerName=?
> permanent;
> rewrite ^/blogs/posts/([^/.]+)/(\d+)/(\d+)/?$
> /blogs.php?action=show_member_blog&ownerName=$1&page=$3&per_page=$2?
> permanent;
> rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/(\d+)/(\d+)/?$
> /blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2&page=$4&per_p
> age=$3? permanent;
>
> rewrite ^/events/?$ /events.php?show_events=all&action=show? permanent;
> rewrite ^/events/all/(\d+)/(\d+)/?$
> /events.php?show_events=all&action=show&page=$2&per_page=$1? permanent;
> rewrite ^/events/part/?$ /events.php?show_events=all&action=show?
> permanent;
> rewrite ^/events/search/?$ /events.php?action=search? permanent;
> rewrite ^/events/search/([^/.]+)/?$
> /events.php?action=search_by_tag&tagKey=$1? permanent;
> rewrite ^/events/my/?$ /events.php?action=show&show_events=my?
> permanent;
> rewrite ^/events/new/?$ /events.php?action=new? permanent;
> rewrite ^/events/entry/([^/.]+)/?$
> /events.php?action=show_info&eventUri=$1? permanent;
> rewrite ^/events/part/([^/.]+)/?$
> /events.php?action=show_part&eventUri=$1?
> permanent;
>
> rewrite ^/ads/?$ /classifieds.php?Browse=1? permanent;
> rewrite ^/ads/search/?$ /classifieds.php?SearchForm=1? permanent;
> rewrite ^/ads/my/?$ /classifiedsmy.php?MyAds=1? permanent;
> rewrite ^/ads/new/?$ /classifiedsmy.php?PostAd=1? permanent;
> rewrite ^/ads/cat/([^/.]+)/?$ /classifieds.php?catUri=$1? permanent;
> rewrite ^/ads/all/cat/(\d+)/(\d+)/([^/.]+)/?$
> /classifieds.php?catUri=$3&page=$2&per_page=$1? permanent;
> rewrite ^/ads/subcat/([^/.]+)/?$ /classifieds.php?scatUri=$1? permanent;
> rewrite ^/ads/all/subcat/(\d+)/(\d+)/([^/.]+)/?$
> /classifieds.php?scatUri=$3&page=$2&per_page=$1? permanent;
> rewrite ^/ads/entry/([^/.]+)/?$ /classifieds.php?entryUri=$1? permanent;
> rewrite ^/ads/tag/([^/.]+)/?$ /classifieds_tags.php?tag=$1? permanent;
>
> rewrite ^/photo/all/(\d+)/(\d+)/?$ /browsePhoto.php?page=$2&per_page=$1?
> permanent;
> rewrite ^/photo/gallery_top/?$ /browsePhoto.php?rate=top? permanent;
> rewrite ^/photo/gallery_top/(\d+)/(\d+)/?$
> /browsePhoto.php?rate=top&page=$2&per_page=$1? permanent;
> rewrite ^/photo/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
> /browsePhoto.php?tag=$1&page=$3&per_page=$2? permanent;
> rewrite ^/photo/gallery_tag/([^/.]+)/?$ /browsePhoto.php?tag=$1?
> permanent;
> rewrite ^/photo/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
> /browsePhoto.php?ownerName=$1&page=$3&per_page=$2? permanent;
> rewrite ^/photo/gallery/all/([^/.]+)/?$ /browsePhoto.php?ownerName=$1?
> permanent;
> rewrite ^/photo/gallery/([^/.]+)/?$ /viewPhoto.php?fileUri=$1?
> permanent;
> rewrite ^/photo/gallery/?$ /viewPhoto.php?fileUri=$1? permanent;
>
> rewrite ^/music/all/(\d+)/(\d+)/?$ /browseMusic.php?page=$2&per_page=$1?
> permanent;
> rewrite ^/music/gallery_top/?$ /browseMusic.php?rate=top? permanent;
> rewrite ^/music/gallery_top/(\d+)/(\d+)/?$
> /browseMusic.php?rate=top&page=$2&per_page=$1? permanent;
> rewrite ^/music/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
> /browseMusic.php?tag=$1&page=$3&per_page=$2? permanent;
> rewrite ^/music/gallery_tag/([^/.]+)/?$ /browseMusic.php?tag=$1?
> permanent;
> rewrite ^/music/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
> /browseMusic.php?ownerName=$1&page=$3&per_page=$2? permanent;
> rewrite ^/music/gallery/all/([^/.]+)/?$ /browseMusic.php?ownerName=$1?
> permanent;
> rewrite ^/music/gallery/([^/.]+)/?$ /viewMusic.php?fileUri=$1?
> permanent;
> rewrite ^/music/gallery/?$ /viewMusic.php?fileUri=$1? permanent;
>
> rewrite ^/video/all/(\d+)/(\d+)/?$ /browseVideo.php?page=$2&per_page=$1?
> permanent;
> rewrite ^/video/gallery_top/?$ /browseVideo.php?rate=top? permanent;
> rewrite ^/video/gallery_top/(\d+)/(\d+)/?$
> /browseVideo.php?rate=top&page=$2&per_page=$1? permanent;
> rewrite ^/video/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
> /browseVideo.php?tag=$1&page=$3&per_page=$2? permanent;
> rewrite ^/video/gallery_tag/([^/.]+)/?$ /browseVideo.php?tag=$1?
> permanent;
> rewrite ^/video/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
> /browseVideo.php?ownerName=$1&page=$3&per_page=$2? permanent;
> rewrite ^/video/gallery/all/([^/.]+)/?$ /browseVideo.php?ownerName=$1?
> permanent;
> rewrite ^/video/gallery/([^/.]+)/?$ /viewVideo.php?fileUri=$1?
> permanent;
> rewrite ^/video/gallery/?$ /viewVideo.php?fileUri=$1? permanent;
>
> rewrite ^/groups/all/?$ /grp.php permanent;
> rewrite ^/groups/entry/([^/.]+)/?$ /grp.php?action=group&groupUri=$1?
> permanent;
> rewrite ^/groups/category/([^/.]+)/?$ /grp.php?action=categ&categUri=$1?
> permanent;
> rewrite ^/groups/keyword/([^/.]+)/?$ /grp.php?action=categ&keyword=$1?
> permanent;
>
> rewrite ^/search/tag/([^/.]+)/?$ /search.php?Tags=$1 permanent;
> --------------------------
>
>
> Maybe using location is better?:
> --------------------------
> location /articles/ {
> rewrite ^/articles/?$ /articles.php;
> rewrite ^/articles/([^/.]+)/?$
> /articles.php?action=viewarticle&articleUri=$1?;
> rewrite ^/articles/category/([^/.]+)/?$
> /articles.php?action=viewcategory&articleCatUri=$1?;
> }
>
> location /news/ {
> rewrite ^/news/?$ /news.php;
> rewrite ^/news/([^/.]+)/?$ /news.php?newsUri=$1?;
> }
>
> location /blogs/ {
> rewrite ^/blogs/?$ /blogs.php;
> rewrite ^/blogs/all/(\d+)/(\d+)/?$ /blogs.php?page=$2&per_page=$1?;
> rewrite ^/blogs/top/?$ /blogs.php?action=top_blogs?;
> rewrite ^/blogs/top/(\d+)/(\d+)/?$
> /blogs.php?action=top_blogs&page=$2&per_page=$1?;
> rewrite ^/blogs/top_posts/?$ /blogs.php?action=top_posts?;
> rewrite ^/blogs/tag/([^/.]+)/?$
> /blogs.php?action=search_by_tag&tagKey=$1?;
> rewrite ^/blogs/tag/?$ /blogs.php?action=search_by_tag&tagKey=?;
> rewrite ^/blogs/posts/([^/.]+)/tag/([^/.]+)/?$
> /blogs.php?action=search_by_tag&tagKey=$2&ownerName=$1?;
> rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/?$
> /blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2?;
> rewrite ^/blogs/entry/([^/.]+)/?$
> /blogs.php?action=show_member_post&postUri=$1?;
> rewrite ^/blogs/entry/?$ /blogs.php?action=show_member_post&postUri=?;
> rewrite ^/blogs/posts/([^/.]+)/?$
> /blogs.php?action=show_member_blog&ownerName=$1?;
> rewrite ^/blogs/posts/?$ /blogs.php?action=show_member_blog&ownerName=?;
> rewrite ^/blogs/posts/([^/.]+)/(\d+)/(\d+)/?$
> /blogs.php?action=show_member_blog&ownerName=$1&page=$3&per_page=$2?;
> rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/(\d+)/(\d+)/?$
> /blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2&page=$4&per_p
> age=$3?;
> }
>
> location /events/ {
> rewrite ^/events/?$ /events.php?show_events=all&action=show?;
> rewrite ^/events/all/(\d+)/(\d+)/?$
> /events.php?show_events=all&action=show&page=$2&per_page=$1?;
> rewrite ^/events/part/?$ /events.php?show_events=all&action=show?;
> rewrite ^/events/search/?$ /events.php?action=search?;
> rewrite ^/events/search/([^/.]+)/?$
> /events.php?action=search_by_tag&tagKey=$1?;
> rewrite ^/events/my/?$ /events.php?action=show&show_events=my?;
> rewrite ^/events/new/?$ /events.php?action=new?;
> rewrite ^/events/entry/([^/.]+)/?$
> /events.php?action=show_info&eventUri=$1?;
> rewrite ^/events/part/([^/.]+)/?$
> /events.php?action=show_part&eventUri=$1?;
> }
>
> location /ads/ {
> rewrite ^/ads/?$ /classifieds.php?Browse=1?;
> rewrite ^/ads/search/?$ /classifieds.php?SearchForm=1?;
> rewrite ^/ads/my/?$ /classifiedsmy.php?MyAds=1?;
> rewrite ^/ads/new/?$ /classifiedsmy.php?PostAd=1?;
> rewrite ^/ads/cat/([^/.]+)/?$ /classifieds.php?catUri=$1?;
> rewrite ^/ads/all/cat/(\d+)/(\d+)/([^/.]+)/?$
> /classifieds.php?catUri=$3&page=$2&per_page=$1?;
> rewrite ^/ads/subcat/([^/.]+)/?$ /classifieds.php?scatUri=$1?;
> rewrite ^/ads/all/subcat/(\d+)/(\d+)/([^/.]+)/?$
> /classifieds.php?scatUri=$3&page=$2&per_page=$1?;
> rewrite ^/ads/entry/([^/.]+)/?$ /classifieds.php?entryUri=$1?;
> rewrite ^/ads/tag/([^/.]+)/?$ /classifieds_tags.php?tag=$1?;
> }
>
> location /photo/ {
> rewrite ^/photo/all/(\d+)/(\d+)/?$
> /browsePhoto.php?page=$2&per_page=$1?;
> rewrite ^/photo/gallery_top/?$ /browsePhoto.php?rate=top?;
> rewrite ^/photo/gallery_top/(\d+)/(\d+)/?$
> /browsePhoto.php?rate=top&page=$2&per_page=$1?;
> rewrite ^/photo/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
> /browsePhoto.php?tag=$1&page=$3&per_page=$2?;
> rewrite ^/photo/gallery_tag/([^/.]+)/?$ /browsePhoto.php?tag=$1?;
> rewrite ^/photo/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
> /browsePhoto.php?ownerName=$1&page=$3&per_page=$2?;
> rewrite ^/photo/gallery/all/([^/.]+)/?$ /browsePhoto.php?ownerName=$1?;
> rewrite ^/photo/gallery/([^/.]+)/?$ /viewPhoto.php?fileUri=$1?;
> rewrite ^/photo/gallery/?$ /viewPhoto.php?fileUri=$1?;
> }
>
> location /music/ {
> rewrite ^/music/all/(\d+)/(\d+)/?$
> /browseMusic.php?page=$2&per_page=$1?;
> rewrite ^/music/gallery_top/?$ /browseMusic.php?rate=top?;
> rewrite ^/music/gallery_top/(\d+)/(\d+)/?$
> /browseMusic.php?rate=top&page=$2&per_page=$1?;
> rewrite ^/music/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
> /browseMusic.php?tag=$1&page=$3&per_page=$2?;
> rewrite ^/music/gallery_tag/([^/.]+)/?$ /browseMusic.php?tag=$1?;
> rewrite ^/music/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
> /browseMusic.php?ownerName=$1&page=$3&per_page=$2?;
> rewrite ^/music/gallery/all/([^/.]+)/?$ /browseMusic.php?ownerName=$1?;
> rewrite ^/music/gallery/([^/.]+)/?$ /viewMusic.php?fileUri=$1?;
> rewrite ^/music/gallery/?$ /viewMusic.php?fileUri=$1?;
> }
>
> location /video/ {
> rewrite ^/video/all/(\d+)/(\d+)/?$
> /browseVideo.php?page=$2&per_page=$1?;
> rewrite ^/video/gallery_top/?$ /browseVideo.php?rate=top?;
> rewrite ^/video/gallery_top/(\d+)/(\d+)/?$
> /browseVideo.php?rate=top&page=$2&per_page=$1?;
> rewrite ^/video/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
> /browseVideo.php?tag=$1&page=$3&per_page=$2?;
> rewrite ^/video/gallery_tag/([^/.]+)/?$ /browseVideo.php?tag=$1?;
> rewrite ^/video/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
> /browseVideo.php?ownerName=$1&page=$3&per_page=$2?;
> rewrite ^/video/gallery/all/([^/.]+)/?$ /browseVideo.php?ownerName=$1?;
> rewrite ^/video/gallery/([^/.]+)/?$ /viewVideo.php?fileUri=$1?;
> rewrite ^/video/gallery/?$ /viewVideo.php?fileUri=$1?;
> }
>
> location /groups/ {
> rewrite ^/groups/all/?$ /grp.php;
> rewrite ^/groups/entry/([^/.]+)/?$ /grp.php?action=group&groupUri=$1?;
> rewrite ^/groups/category/([^/.]+)/?$
> /grp.php?action=categ&categUri=$1?;
> rewrite ^/groups/keyword/([^/.]+)/?$ /grp.php?action=categ&keyword=$1?;
> }
>
> location /search/tag/ {
> rewrite ^/search/tag/([^/.]+)/?$ /search.php?Tags=$1?;
> }
>
> location / {
> try_files $uri $uri/ /profile.php?ID=$uri;
> }
> --------------------------
>
>
>
> >
> > RewriteCond %{REQUEST_FILENAME} -f [OR]
> > RewriteCond %{REQUEST_FILENAME} -d
> > RewriteRule .+ - [L]
> > RewriteRule ^([A-Za-z0-9_-]+)$ profile.php?ID=$1 [QSA,L]
> >
> Those here could be done with a try rule. Something like:
> --------------------------
> location / {
> try_files $uri $uri/ /profile.php?ID=$uri;
> }
> --------------------------
>
> Or:
> --------------------------
> location / {
> if (-e $request_filename) {
> set $ampr01 1;
> }
> if ($request_filename ~* "^([A-Za-z0-9_-]+)$") {
> set $ampr02 1;
> }
> if ($ampr01$ampr02 = "11") {
> rewrite ^/([A-Za-z0-9_-]+)$ /profile.php?ID=$1 last;
> break;
> }
> }
> --------------------------
>
>
> I have not tested those rules. I don't know if they work.
>
>
> > Regards,
> >
> Kind Regards,
>
> > -Team AMP
> >
> Steve
>
>
> > http://www.ampprod.com
> >
>
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx

--
Preisknaller: GMX DSL Flatrate für nur 16,99 Euro/mtl.!
http://portal.gmx.net/de/go/dsl02

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: Include don't Loading have Variables Path

Hello!

On Wed, Dec 30, 2009 at 08:54:58AM +0100, Nginx fans wrote:

[...]

> include $web_root/.htaccess; This is load Rewrite Rule for nginx
> But Nginx don't load why?
>
> [emerg]: CreateFile() "D:\nginx/conf/$web_root\.htaccess" failed (3: The
> system cannot find the path specified) in D:\nginx/conf/nginx.conf:42

Variables in nginx are evaluated at run time for each request. On
the other hand, configuration is loaded and parsed during startup.
So you can't use variables for things needed during configuration
parsing, e.g. "include".

Moreover, you don't need variables to set root. It doesn't change
between requests. Using variables here is just waste of
resources, warming the world for no reason. You don't need
variables, you need configuration macros which are expanded at
time of reading configuration.

nginx doesn't support configuration macros, but they are
trivially added by any config generation tools (e.g. make + sed
will do the trick).

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: var/www

Rob Schultz wrote:
> Paul,
> This is an example of trimmed down passenger setup i am using with nginx
> V/r,
> Rob Schultz

Hello Rob,

Thanks for your answer - over in Europe, so sound asleep when you
replied!

I have had a look around the configurations questions that I can find
for nginx, but nothing seems to answer the problem I have.

The computer that I am using for trials has had apache2 installed on it,
ruby, rails etc. as well. The idea is that I would like to create an
environment similar to the web server (running Ubuntu 8.10 server with
eBox), so that I know what to do with that when the installation on the
laptop is successful. I am looking to remove apache2 from the web server
and replace it with nginx, so
I did that on the laptop first.

A quick side question - do you know whether I can run nginx as well as
apache2 on the server? nginx would handle all ports except eBox
administration. Just a thought - not important really, but I am not sure
whether eBox needs apache2.

The web server will have two domains to host from the same fixed IP, and
needs SSL for one of them.

The trial computer now has all apache2 files taken off, and nginx is now
the web server. One of the web sites will be a rails site.

The rails site on the trial computer is at /home/paul/sites/my_app/, and
has all the usual sub-directories created by rails. I don't know where
to put the rails files on the web server at present.

For the moment, the only hostname on the laptop is localhost.

*The server uses squirrelmail with postfix. I have it set up currently
for IMAP. This I do not have on the laptop, but it is important for the
web- server!

There seem to be 4 files with configuration for gninx it them:

/var/nginx/conf/nginx.conf (this one I changed - probably the wrong
one!)
/etc/nginx/nginx.conf (no changed made since installation)
/etc/nginx/sites-available/default (no changed made since installation)
/etc/nginx/sites-enabled/default (no changed made since installation)

(virtual host, ssl and php are # out at present - I take it that is
default)

So, please could you tell me which file should be edit, and what to put
in to achieve all/some of this?

Thanks in advance for your time!

Kind regards
Paul

--
Posted via http://www.ruby-forum.com/.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

AIO cause memory leak

I got the memory leak error on my linux server when I added 'aio on;' in my nginx.conf,
The os is fedora 11
(x86-64) and gentoo(x86-64),The kernel is 2.6.29+.
I've already set 'directio 2m; sendfile on; ' into nginx.conf.
The server is only serving static flv contents,
These is 50-100MBytes each flv file.

When 'aio on' is setting, the server's 4G memory and 2G swap were consumed by nginx, work_processes just 4.
When I disable aio, each nginx processes used 30M memory only.

When aio is used, I know it should disable sendfile and use directio, Why it use so many memory?


2009年12月29日星期二

Include don't Loading have Variables Path

server {
listen 80;
server_name localhost;

charset utf-8;

location / {
set $web_root d:/website/wordpress;
root $web_root;
index index.html index.htm index.php;
}

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 $web_root;
}

location ~ \.php$ {
root $web_root;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$web_root$fastcgi_script_name;
include fastcgi_params;
}

include $web_root/.htaccess;

}


###
include $web_root/.htaccess; This is load Rewrite Rule for nginx
But Nginx don't load why?

[emerg]: CreateFile() "D:\nginx/conf/$web_root\.htaccess" failed (3: The
system cannot find the path specified) in D:\nginx/conf/nginx.conf:42


How should I do? How do NGINX make it support.
please thanks.
--
Posted via http://www.ruby-forum.com/.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: Directory fallback

On Tue, Dec 29, 2009 at 3:27 PM, Tobia Conforto
<tobia.conforto@gmail.com> wrote:
> merlin corey wrote:
>> Make an attempt at least! :-)
>
> Actually, I posted after 2 hours of failed attempts :(
>
>> I'll get you started... please note this is written for 0.8.30 and above and I didn't test this, but it should be close.
>
> Eh, I was using 0.6.32, maybe that's why I wasn't going far.
> Thank you for your example, tomorrow I'll work on it.
>
> This, for example, I wouldn't have guessed in a million years:
>
>> fastcgi_intercept_errors on;
>> ...
>> error_page 404 = @basephp
>
> This is also pretty ingenious:
>
>> fastcgi_param SCRIPT_FILENAME /var/www/base$fastcgi_script_name;
>
> Many thanks!
>
> Tobia
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>

You're welcome. Please note a small typo, I did not end the
error_page declaration with a semicolon. There might be other small
errors I apologize for :). If you review the documentation at
http://wiki.nginx.org regarding these directives it should all be very
clear to you :).

Good luck!
-- Merlin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: Traffic limit and HTTP headers rewrite

On Sun, Dec 27, 2009 at 7:30 PM, Aryanto Rachmad
<aryanto.rachmad@chello.at> wrote:

> And I want to try Nginx, but I can not find any where in the documentations
> about how to do the HTTP header re-write. What I would like to do is to be
> able to re-write the HTTP header set by Drupal, especially the "Expires",
> "Cache-Control", "Last-Modified", "Content-Encoding" and "Content-Type"
> headers. I am using Lighttpd and I can do the removal and re-write of those
> HTTP headers via mod_magnet LUA script. Is there similar function like that
> in Nginx, which allow me to do that without changing anything in Drupal?

I don't know if this can help you, but you can take a look.

http://wiki.nginx.org/NginxHttpHeadersModule
http://wiki.nginx.org/NginxHttpHeadersMoreModule

Cecep

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

RE: i've been trying to convert this .htaccess for a week now

Wow! This is awesome! I'll start working with this and see what I can come
up with.

Btw, I'm running Nginx 0.7.64

-----Original Message-----
From: Steve [mailto:steeeeeveee@gmx.net]
Sent: Tuesday, December 29, 2009 7:53 PM
To: nginx@nginx.org
Subject: Re: i've been trying to convert this .htaccess for a week now


-------- Original-Nachricht --------
> Datum: Mon, 28 Dec 2009 20:24:14 -0600
> Von: "AMP Admin" <admin@ampprod.com>
> An: nginx@nginx.org
> Betreff: i\'ve been trying to convert this .htaccess for a week now

> I hate to ask but this one is just too big and complicated for me to
> convert. Any help would be good. Thanks!
>
>
>
[removed long list of Apache Rewrite rules]
>
>
Since I don't know where you need those rewrites and what version of nginx
you are using and how you have setup the other stuff in nginx I am not able
to optimize the rewrite rules (some stuff can be done without rewriting when
using newer version of nginx). Anyway.... here a suggestion (you might need
to change "permanent" to "last" or in some cases to "break" but all this
depends where you add those rewrite rules in your nginx.conf):
--------------------------
rewrite ^/articles/?$ /articles.php permanent;
rewrite ^/articles/([^/.]+)/?$
/articles.php?action=viewarticle&articleUri=$1? permanent;
rewrite ^/articles/category/([^/.]+)/?$
/articles.php?action=viewcategory&articleCatUri=$1? permanent;

rewrite ^/news/?$ /news.php permanent;
rewrite ^/news/([^/.]+)/?$ /news.php?newsUri=$1? permanent;

rewrite ^/blogs/?$ /blogs.php permanent;
rewrite ^/blogs/all/(\d+)/(\d+)/?$ /blogs.php?page=$2&per_page=$1?
permanent;
rewrite ^/blogs/top/?$ /blogs.php?action=top_blogs? permanent;
rewrite ^/blogs/top/(\d+)/(\d+)/?$
/blogs.php?action=top_blogs&page=$2&per_page=$1? permanent;
rewrite ^/blogs/top_posts/?$ /blogs.php?action=top_posts? permanent;
rewrite ^/blogs/tag/([^/.]+)/?$ /blogs.php?action=search_by_tag&tagKey=$1?
permanent;
rewrite ^/blogs/tag/?$ /blogs.php?action=search_by_tag&tagKey=? permanent;
rewrite ^/blogs/posts/([^/.]+)/tag/([^/.]+)/?$
/blogs.php?action=search_by_tag&tagKey=$2&ownerName=$1? permanent;
rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/?$
/blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2? permanent;
rewrite ^/blogs/entry/([^/.]+)/?$
/blogs.php?action=show_member_post&postUri=$1? permanent;
rewrite ^/blogs/entry/?$ /blogs.php?action=show_member_post&postUri=?
permanent;
rewrite ^/blogs/posts/([^/.]+)/?$
/blogs.php?action=show_member_blog&ownerName=$1? permanent;
rewrite ^/blogs/posts/?$ /blogs.php?action=show_member_blog&ownerName=?
permanent;
rewrite ^/blogs/posts/([^/.]+)/(\d+)/(\d+)/?$
/blogs.php?action=show_member_blog&ownerName=$1&page=$3&per_page=$2?
permanent;
rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/(\d+)/(\d+)/?$
/blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2&page=$4&per_p
age=$3? permanent;

rewrite ^/events/?$ /events.php?show_events=all&action=show? permanent;
rewrite ^/events/all/(\d+)/(\d+)/?$
/events.php?show_events=all&action=show&page=$2&per_page=$1? permanent;
rewrite ^/events/part/?$ /events.php?show_events=all&action=show?
permanent;
rewrite ^/events/search/?$ /events.php?action=search? permanent;
rewrite ^/events/search/([^/.]+)/?$
/events.php?action=search_by_tag&tagKey=$1? permanent;
rewrite ^/events/my/?$ /events.php?action=show&show_events=my? permanent;
rewrite ^/events/new/?$ /events.php?action=new? permanent;
rewrite ^/events/entry/([^/.]+)/?$
/events.php?action=show_info&eventUri=$1? permanent;
rewrite ^/events/part/([^/.]+)/?$ /events.php?action=show_part&eventUri=$1?
permanent;

rewrite ^/ads/?$ /classifieds.php?Browse=1? permanent;
rewrite ^/ads/search/?$ /classifieds.php?SearchForm=1? permanent;
rewrite ^/ads/my/?$ /classifiedsmy.php?MyAds=1? permanent;
rewrite ^/ads/new/?$ /classifiedsmy.php?PostAd=1? permanent;
rewrite ^/ads/cat/([^/.]+)/?$ /classifieds.php?catUri=$1? permanent;
rewrite ^/ads/all/cat/(\d+)/(\d+)/([^/.]+)/?$
/classifieds.php?catUri=$3&page=$2&per_page=$1? permanent;
rewrite ^/ads/subcat/([^/.]+)/?$ /classifieds.php?scatUri=$1? permanent;
rewrite ^/ads/all/subcat/(\d+)/(\d+)/([^/.]+)/?$
/classifieds.php?scatUri=$3&page=$2&per_page=$1? permanent;
rewrite ^/ads/entry/([^/.]+)/?$ /classifieds.php?entryUri=$1? permanent;
rewrite ^/ads/tag/([^/.]+)/?$ /classifieds_tags.php?tag=$1? permanent;

rewrite ^/photo/all/(\d+)/(\d+)/?$ /browsePhoto.php?page=$2&per_page=$1?
permanent;
rewrite ^/photo/gallery_top/?$ /browsePhoto.php?rate=top? permanent;
rewrite ^/photo/gallery_top/(\d+)/(\d+)/?$
/browsePhoto.php?rate=top&page=$2&per_page=$1? permanent;
rewrite ^/photo/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
/browsePhoto.php?tag=$1&page=$3&per_page=$2? permanent;
rewrite ^/photo/gallery_tag/([^/.]+)/?$ /browsePhoto.php?tag=$1?
permanent;
rewrite ^/photo/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
/browsePhoto.php?ownerName=$1&page=$3&per_page=$2? permanent;
rewrite ^/photo/gallery/all/([^/.]+)/?$ /browsePhoto.php?ownerName=$1?
permanent;
rewrite ^/photo/gallery/([^/.]+)/?$ /viewPhoto.php?fileUri=$1? permanent;
rewrite ^/photo/gallery/?$ /viewPhoto.php?fileUri=$1? permanent;

rewrite ^/music/all/(\d+)/(\d+)/?$ /browseMusic.php?page=$2&per_page=$1?
permanent;
rewrite ^/music/gallery_top/?$ /browseMusic.php?rate=top? permanent;
rewrite ^/music/gallery_top/(\d+)/(\d+)/?$
/browseMusic.php?rate=top&page=$2&per_page=$1? permanent;
rewrite ^/music/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
/browseMusic.php?tag=$1&page=$3&per_page=$2? permanent;
rewrite ^/music/gallery_tag/([^/.]+)/?$ /browseMusic.php?tag=$1?
permanent;
rewrite ^/music/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
/browseMusic.php?ownerName=$1&page=$3&per_page=$2? permanent;
rewrite ^/music/gallery/all/([^/.]+)/?$ /browseMusic.php?ownerName=$1?
permanent;
rewrite ^/music/gallery/([^/.]+)/?$ /viewMusic.php?fileUri=$1? permanent;
rewrite ^/music/gallery/?$ /viewMusic.php?fileUri=$1? permanent;

rewrite ^/video/all/(\d+)/(\d+)/?$ /browseVideo.php?page=$2&per_page=$1?
permanent;
rewrite ^/video/gallery_top/?$ /browseVideo.php?rate=top? permanent;
rewrite ^/video/gallery_top/(\d+)/(\d+)/?$
/browseVideo.php?rate=top&page=$2&per_page=$1? permanent;
rewrite ^/video/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
/browseVideo.php?tag=$1&page=$3&per_page=$2? permanent;
rewrite ^/video/gallery_tag/([^/.]+)/?$ /browseVideo.php?tag=$1?
permanent;
rewrite ^/video/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
/browseVideo.php?ownerName=$1&page=$3&per_page=$2? permanent;
rewrite ^/video/gallery/all/([^/.]+)/?$ /browseVideo.php?ownerName=$1?
permanent;
rewrite ^/video/gallery/([^/.]+)/?$ /viewVideo.php?fileUri=$1? permanent;
rewrite ^/video/gallery/?$ /viewVideo.php?fileUri=$1? permanent;

rewrite ^/groups/all/?$ /grp.php permanent;
rewrite ^/groups/entry/([^/.]+)/?$ /grp.php?action=group&groupUri=$1?
permanent;
rewrite ^/groups/category/([^/.]+)/?$ /grp.php?action=categ&categUri=$1?
permanent;
rewrite ^/groups/keyword/([^/.]+)/?$ /grp.php?action=categ&keyword=$1?
permanent;

rewrite ^/search/tag/([^/.]+)/?$ /search.php?Tags=$1 permanent;
--------------------------


Maybe using location is better?:
--------------------------
location /articles/ {
rewrite ^/articles/?$ /articles.php;
rewrite ^/articles/([^/.]+)/?$
/articles.php?action=viewarticle&articleUri=$1?;
rewrite ^/articles/category/([^/.]+)/?$
/articles.php?action=viewcategory&articleCatUri=$1?;
}

location /news/ {
rewrite ^/news/?$ /news.php;
rewrite ^/news/([^/.]+)/?$ /news.php?newsUri=$1?;
}

location /blogs/ {
rewrite ^/blogs/?$ /blogs.php;
rewrite ^/blogs/all/(\d+)/(\d+)/?$ /blogs.php?page=$2&per_page=$1?;
rewrite ^/blogs/top/?$ /blogs.php?action=top_blogs?;
rewrite ^/blogs/top/(\d+)/(\d+)/?$
/blogs.php?action=top_blogs&page=$2&per_page=$1?;
rewrite ^/blogs/top_posts/?$ /blogs.php?action=top_posts?;
rewrite ^/blogs/tag/([^/.]+)/?$
/blogs.php?action=search_by_tag&tagKey=$1?;
rewrite ^/blogs/tag/?$ /blogs.php?action=search_by_tag&tagKey=?;
rewrite ^/blogs/posts/([^/.]+)/tag/([^/.]+)/?$
/blogs.php?action=search_by_tag&tagKey=$2&ownerName=$1?;
rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/?$
/blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2?;
rewrite ^/blogs/entry/([^/.]+)/?$
/blogs.php?action=show_member_post&postUri=$1?;
rewrite ^/blogs/entry/?$ /blogs.php?action=show_member_post&postUri=?;
rewrite ^/blogs/posts/([^/.]+)/?$
/blogs.php?action=show_member_blog&ownerName=$1?;
rewrite ^/blogs/posts/?$ /blogs.php?action=show_member_blog&ownerName=?;
rewrite ^/blogs/posts/([^/.]+)/(\d+)/(\d+)/?$
/blogs.php?action=show_member_blog&ownerName=$1&page=$3&per_page=$2?;
rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/(\d+)/(\d+)/?$
/blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2&page=$4&per_p
age=$3?;
}

location /events/ {
rewrite ^/events/?$ /events.php?show_events=all&action=show?;
rewrite ^/events/all/(\d+)/(\d+)/?$
/events.php?show_events=all&action=show&page=$2&per_page=$1?;
rewrite ^/events/part/?$ /events.php?show_events=all&action=show?;
rewrite ^/events/search/?$ /events.php?action=search?;
rewrite ^/events/search/([^/.]+)/?$
/events.php?action=search_by_tag&tagKey=$1?;
rewrite ^/events/my/?$ /events.php?action=show&show_events=my?;
rewrite ^/events/new/?$ /events.php?action=new?;
rewrite ^/events/entry/([^/.]+)/?$
/events.php?action=show_info&eventUri=$1?;
rewrite ^/events/part/([^/.]+)/?$
/events.php?action=show_part&eventUri=$1?;
}

location /ads/ {
rewrite ^/ads/?$ /classifieds.php?Browse=1?;
rewrite ^/ads/search/?$ /classifieds.php?SearchForm=1?;
rewrite ^/ads/my/?$ /classifiedsmy.php?MyAds=1?;
rewrite ^/ads/new/?$ /classifiedsmy.php?PostAd=1?;
rewrite ^/ads/cat/([^/.]+)/?$ /classifieds.php?catUri=$1?;
rewrite ^/ads/all/cat/(\d+)/(\d+)/([^/.]+)/?$
/classifieds.php?catUri=$3&page=$2&per_page=$1?;
rewrite ^/ads/subcat/([^/.]+)/?$ /classifieds.php?scatUri=$1?;
rewrite ^/ads/all/subcat/(\d+)/(\d+)/([^/.]+)/?$
/classifieds.php?scatUri=$3&page=$2&per_page=$1?;
rewrite ^/ads/entry/([^/.]+)/?$ /classifieds.php?entryUri=$1?;
rewrite ^/ads/tag/([^/.]+)/?$ /classifieds_tags.php?tag=$1?;
}

location /photo/ {
rewrite ^/photo/all/(\d+)/(\d+)/?$ /browsePhoto.php?page=$2&per_page=$1?;
rewrite ^/photo/gallery_top/?$ /browsePhoto.php?rate=top?;
rewrite ^/photo/gallery_top/(\d+)/(\d+)/?$
/browsePhoto.php?rate=top&page=$2&per_page=$1?;
rewrite ^/photo/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
/browsePhoto.php?tag=$1&page=$3&per_page=$2?;
rewrite ^/photo/gallery_tag/([^/.]+)/?$ /browsePhoto.php?tag=$1?;
rewrite ^/photo/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
/browsePhoto.php?ownerName=$1&page=$3&per_page=$2?;
rewrite ^/photo/gallery/all/([^/.]+)/?$ /browsePhoto.php?ownerName=$1?;
rewrite ^/photo/gallery/([^/.]+)/?$ /viewPhoto.php?fileUri=$1?;
rewrite ^/photo/gallery/?$ /viewPhoto.php?fileUri=$1?;
}

location /music/ {
rewrite ^/music/all/(\d+)/(\d+)/?$ /browseMusic.php?page=$2&per_page=$1?;
rewrite ^/music/gallery_top/?$ /browseMusic.php?rate=top?;
rewrite ^/music/gallery_top/(\d+)/(\d+)/?$
/browseMusic.php?rate=top&page=$2&per_page=$1?;
rewrite ^/music/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
/browseMusic.php?tag=$1&page=$3&per_page=$2?;
rewrite ^/music/gallery_tag/([^/.]+)/?$ /browseMusic.php?tag=$1?;
rewrite ^/music/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
/browseMusic.php?ownerName=$1&page=$3&per_page=$2?;
rewrite ^/music/gallery/all/([^/.]+)/?$ /browseMusic.php?ownerName=$1?;
rewrite ^/music/gallery/([^/.]+)/?$ /viewMusic.php?fileUri=$1?;
rewrite ^/music/gallery/?$ /viewMusic.php?fileUri=$1?;
}

location /video/ {
rewrite ^/video/all/(\d+)/(\d+)/?$ /browseVideo.php?page=$2&per_page=$1?;
rewrite ^/video/gallery_top/?$ /browseVideo.php?rate=top?;
rewrite ^/video/gallery_top/(\d+)/(\d+)/?$
/browseVideo.php?rate=top&page=$2&per_page=$1?;
rewrite ^/video/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$
/browseVideo.php?tag=$1&page=$3&per_page=$2?;
rewrite ^/video/gallery_tag/([^/.]+)/?$ /browseVideo.php?tag=$1?;
rewrite ^/video/gallery/all/([^/.]+)/(\d+)/(\d+)/?$
/browseVideo.php?ownerName=$1&page=$3&per_page=$2?;
rewrite ^/video/gallery/all/([^/.]+)/?$ /browseVideo.php?ownerName=$1?;
rewrite ^/video/gallery/([^/.]+)/?$ /viewVideo.php?fileUri=$1?;
rewrite ^/video/gallery/?$ /viewVideo.php?fileUri=$1?;
}

location /groups/ {
rewrite ^/groups/all/?$ /grp.php;
rewrite ^/groups/entry/([^/.]+)/?$ /grp.php?action=group&groupUri=$1?;
rewrite ^/groups/category/([^/.]+)/?$ /grp.php?action=categ&categUri=$1?;
rewrite ^/groups/keyword/([^/.]+)/?$ /grp.php?action=categ&keyword=$1?;
}

location /search/tag/ {
rewrite ^/search/tag/([^/.]+)/?$ /search.php?Tags=$1?;
}

location / {
try_files $uri $uri/ /profile.php?ID=$uri;
}
--------------------------

>
> RewriteCond %{REQUEST_FILENAME} -f [OR]
> RewriteCond %{REQUEST_FILENAME} -d
> RewriteRule .+ - [L]
> RewriteRule ^([A-Za-z0-9_-]+)$ profile.php?ID=$1 [QSA,L]
>
Those here could be done with a try rule. Something like:
--------------------------
location / {
try_files $uri $uri/ /profile.php?ID=$uri;
}
--------------------------

Or:
--------------------------
location / {
if (-e $request_filename) {
set $ampr01 1;
}
if ($request_filename ~* "^([A-Za-z0-9_-]+)$") {
set $ampr02 1;
}
if ($ampr01$ampr02 = "11") {
rewrite ^/([A-Za-z0-9_-]+)$ /profile.php?ID=$1 last;
break;
}
}
--------------------------


I have not tested those rules. I don't know if they work.


> Regards,
>
Kind Regards,

> -Team AMP
>
Steve


> http://www.ampprod.com
>

--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Re: i've been trying to convert this .htaccess for a week now

-------- Original-Nachricht --------
> Datum: Mon, 28 Dec 2009 20:24:14 -0600
> Von: "AMP Admin" <admin@ampprod.com>
> An: nginx@nginx.org
> Betreff: i\'ve been trying to convert this .htaccess for a week now

> I hate to ask but this one is just too big and complicated for me to
> convert. Any help would be good. Thanks!
>
>
>
[removed long list of Apache Rewrite rules]
>
>
Since I don't know where you need those rewrites and what version of nginx you are using and how you have setup the other stuff in nginx I am not able to optimize the rewrite rules (some stuff can be done without rewriting when using newer version of nginx). Anyway.... here a suggestion (you might need to change "permanent" to "last" or in some cases to "break" but all this depends where you add those rewrite rules in your nginx.conf):
--------------------------
rewrite ^/articles/?$ /articles.php permanent;
rewrite ^/articles/([^/.]+)/?$ /articles.php?action=viewarticle&articleUri=$1? permanent;
rewrite ^/articles/category/([^/.]+)/?$ /articles.php?action=viewcategory&articleCatUri=$1? permanent;

rewrite ^/news/?$ /news.php permanent;
rewrite ^/news/([^/.]+)/?$ /news.php?newsUri=$1? permanent;

rewrite ^/blogs/?$ /blogs.php permanent;
rewrite ^/blogs/all/(\d+)/(\d+)/?$ /blogs.php?page=$2&per_page=$1? permanent;
rewrite ^/blogs/top/?$ /blogs.php?action=top_blogs? permanent;
rewrite ^/blogs/top/(\d+)/(\d+)/?$ /blogs.php?action=top_blogs&page=$2&per_page=$1? permanent;
rewrite ^/blogs/top_posts/?$ /blogs.php?action=top_posts? permanent;
rewrite ^/blogs/tag/([^/.]+)/?$ /blogs.php?action=search_by_tag&tagKey=$1? permanent;
rewrite ^/blogs/tag/?$ /blogs.php?action=search_by_tag&tagKey=? permanent;
rewrite ^/blogs/posts/([^/.]+)/tag/([^/.]+)/?$ /blogs.php?action=search_by_tag&tagKey=$2&ownerName=$1? permanent;
rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/?$ /blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2? permanent;
rewrite ^/blogs/entry/([^/.]+)/?$ /blogs.php?action=show_member_post&postUri=$1? permanent;
rewrite ^/blogs/entry/?$ /blogs.php?action=show_member_post&postUri=? permanent;
rewrite ^/blogs/posts/([^/.]+)/?$ /blogs.php?action=show_member_blog&ownerName=$1? permanent;
rewrite ^/blogs/posts/?$ /blogs.php?action=show_member_blog&ownerName=? permanent;
rewrite ^/blogs/posts/([^/.]+)/(\d+)/(\d+)/?$ /blogs.php?action=show_member_blog&ownerName=$1&page=$3&per_page=$2? permanent;
rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/(\d+)/(\d+)/?$ /blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2&page=$4&per_page=$3? permanent;

rewrite ^/events/?$ /events.php?show_events=all&action=show? permanent;
rewrite ^/events/all/(\d+)/(\d+)/?$ /events.php?show_events=all&action=show&page=$2&per_page=$1? permanent;
rewrite ^/events/part/?$ /events.php?show_events=all&action=show? permanent;
rewrite ^/events/search/?$ /events.php?action=search? permanent;
rewrite ^/events/search/([^/.]+)/?$ /events.php?action=search_by_tag&tagKey=$1? permanent;
rewrite ^/events/my/?$ /events.php?action=show&show_events=my? permanent;
rewrite ^/events/new/?$ /events.php?action=new? permanent;
rewrite ^/events/entry/([^/.]+)/?$ /events.php?action=show_info&eventUri=$1? permanent;
rewrite ^/events/part/([^/.]+)/?$ /events.php?action=show_part&eventUri=$1? permanent;

rewrite ^/ads/?$ /classifieds.php?Browse=1? permanent;
rewrite ^/ads/search/?$ /classifieds.php?SearchForm=1? permanent;
rewrite ^/ads/my/?$ /classifiedsmy.php?MyAds=1? permanent;
rewrite ^/ads/new/?$ /classifiedsmy.php?PostAd=1? permanent;
rewrite ^/ads/cat/([^/.]+)/?$ /classifieds.php?catUri=$1? permanent;
rewrite ^/ads/all/cat/(\d+)/(\d+)/([^/.]+)/?$ /classifieds.php?catUri=$3&page=$2&per_page=$1? permanent;
rewrite ^/ads/subcat/([^/.]+)/?$ /classifieds.php?scatUri=$1? permanent;
rewrite ^/ads/all/subcat/(\d+)/(\d+)/([^/.]+)/?$ /classifieds.php?scatUri=$3&page=$2&per_page=$1? permanent;
rewrite ^/ads/entry/([^/.]+)/?$ /classifieds.php?entryUri=$1? permanent;
rewrite ^/ads/tag/([^/.]+)/?$ /classifieds_tags.php?tag=$1? permanent;

rewrite ^/photo/all/(\d+)/(\d+)/?$ /browsePhoto.php?page=$2&per_page=$1? permanent;
rewrite ^/photo/gallery_top/?$ /browsePhoto.php?rate=top? permanent;
rewrite ^/photo/gallery_top/(\d+)/(\d+)/?$ /browsePhoto.php?rate=top&page=$2&per_page=$1? permanent;
rewrite ^/photo/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$ /browsePhoto.php?tag=$1&page=$3&per_page=$2? permanent;
rewrite ^/photo/gallery_tag/([^/.]+)/?$ /browsePhoto.php?tag=$1? permanent;
rewrite ^/photo/gallery/all/([^/.]+)/(\d+)/(\d+)/?$ /browsePhoto.php?ownerName=$1&page=$3&per_page=$2? permanent;
rewrite ^/photo/gallery/all/([^/.]+)/?$ /browsePhoto.php?ownerName=$1? permanent;
rewrite ^/photo/gallery/([^/.]+)/?$ /viewPhoto.php?fileUri=$1? permanent;
rewrite ^/photo/gallery/?$ /viewPhoto.php?fileUri=$1? permanent;

rewrite ^/music/all/(\d+)/(\d+)/?$ /browseMusic.php?page=$2&per_page=$1? permanent;
rewrite ^/music/gallery_top/?$ /browseMusic.php?rate=top? permanent;
rewrite ^/music/gallery_top/(\d+)/(\d+)/?$ /browseMusic.php?rate=top&page=$2&per_page=$1? permanent;
rewrite ^/music/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$ /browseMusic.php?tag=$1&page=$3&per_page=$2? permanent;
rewrite ^/music/gallery_tag/([^/.]+)/?$ /browseMusic.php?tag=$1? permanent;
rewrite ^/music/gallery/all/([^/.]+)/(\d+)/(\d+)/?$ /browseMusic.php?ownerName=$1&page=$3&per_page=$2? permanent;
rewrite ^/music/gallery/all/([^/.]+)/?$ /browseMusic.php?ownerName=$1? permanent;
rewrite ^/music/gallery/([^/.]+)/?$ /viewMusic.php?fileUri=$1? permanent;
rewrite ^/music/gallery/?$ /viewMusic.php?fileUri=$1? permanent;

rewrite ^/video/all/(\d+)/(\d+)/?$ /browseVideo.php?page=$2&per_page=$1? permanent;
rewrite ^/video/gallery_top/?$ /browseVideo.php?rate=top? permanent;
rewrite ^/video/gallery_top/(\d+)/(\d+)/?$ /browseVideo.php?rate=top&page=$2&per_page=$1? permanent;
rewrite ^/video/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$ /browseVideo.php?tag=$1&page=$3&per_page=$2? permanent;
rewrite ^/video/gallery_tag/([^/.]+)/?$ /browseVideo.php?tag=$1? permanent;
rewrite ^/video/gallery/all/([^/.]+)/(\d+)/(\d+)/?$ /browseVideo.php?ownerName=$1&page=$3&per_page=$2? permanent;
rewrite ^/video/gallery/all/([^/.]+)/?$ /browseVideo.php?ownerName=$1? permanent;
rewrite ^/video/gallery/([^/.]+)/?$ /viewVideo.php?fileUri=$1? permanent;
rewrite ^/video/gallery/?$ /viewVideo.php?fileUri=$1? permanent;

rewrite ^/groups/all/?$ /grp.php permanent;
rewrite ^/groups/entry/([^/.]+)/?$ /grp.php?action=group&groupUri=$1? permanent;
rewrite ^/groups/category/([^/.]+)/?$ /grp.php?action=categ&categUri=$1? permanent;
rewrite ^/groups/keyword/([^/.]+)/?$ /grp.php?action=categ&keyword=$1? permanent;

rewrite ^/search/tag/([^/.]+)/?$ /search.php?Tags=$1 permanent;
--------------------------


Maybe using location is better?:
--------------------------
location /articles/ {
rewrite ^/articles/?$ /articles.php;
rewrite ^/articles/([^/.]+)/?$ /articles.php?action=viewarticle&articleUri=$1?;
rewrite ^/articles/category/([^/.]+)/?$ /articles.php?action=viewcategory&articleCatUri=$1?;
}

location /news/ {
rewrite ^/news/?$ /news.php;
rewrite ^/news/([^/.]+)/?$ /news.php?newsUri=$1?;
}

location /blogs/ {
rewrite ^/blogs/?$ /blogs.php;
rewrite ^/blogs/all/(\d+)/(\d+)/?$ /blogs.php?page=$2&per_page=$1?;
rewrite ^/blogs/top/?$ /blogs.php?action=top_blogs?;
rewrite ^/blogs/top/(\d+)/(\d+)/?$ /blogs.php?action=top_blogs&page=$2&per_page=$1?;
rewrite ^/blogs/top_posts/?$ /blogs.php?action=top_posts?;
rewrite ^/blogs/tag/([^/.]+)/?$ /blogs.php?action=search_by_tag&tagKey=$1?;
rewrite ^/blogs/tag/?$ /blogs.php?action=search_by_tag&tagKey=?;
rewrite ^/blogs/posts/([^/.]+)/tag/([^/.]+)/?$ /blogs.php?action=search_by_tag&tagKey=$2&ownerName=$1?;
rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/?$ /blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2?;
rewrite ^/blogs/entry/([^/.]+)/?$ /blogs.php?action=show_member_post&postUri=$1?;
rewrite ^/blogs/entry/?$ /blogs.php?action=show_member_post&postUri=?;
rewrite ^/blogs/posts/([^/.]+)/?$ /blogs.php?action=show_member_blog&ownerName=$1?;
rewrite ^/blogs/posts/?$ /blogs.php?action=show_member_blog&ownerName=?;
rewrite ^/blogs/posts/([^/.]+)/(\d+)/(\d+)/?$ /blogs.php?action=show_member_blog&ownerName=$1&page=$3&per_page=$2?;
rewrite ^/blogs/posts/([^/.]+)/category/([^/.]+)/(\d+)/(\d+)/?$ /blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2&page=$4&per_page=$3?;
}

location /events/ {
rewrite ^/events/?$ /events.php?show_events=all&action=show?;
rewrite ^/events/all/(\d+)/(\d+)/?$ /events.php?show_events=all&action=show&page=$2&per_page=$1?;
rewrite ^/events/part/?$ /events.php?show_events=all&action=show?;
rewrite ^/events/search/?$ /events.php?action=search?;
rewrite ^/events/search/([^/.]+)/?$ /events.php?action=search_by_tag&tagKey=$1?;
rewrite ^/events/my/?$ /events.php?action=show&show_events=my?;
rewrite ^/events/new/?$ /events.php?action=new?;
rewrite ^/events/entry/([^/.]+)/?$ /events.php?action=show_info&eventUri=$1?;
rewrite ^/events/part/([^/.]+)/?$ /events.php?action=show_part&eventUri=$1?;
}

location /ads/ {
rewrite ^/ads/?$ /classifieds.php?Browse=1?;
rewrite ^/ads/search/?$ /classifieds.php?SearchForm=1?;
rewrite ^/ads/my/?$ /classifiedsmy.php?MyAds=1?;
rewrite ^/ads/new/?$ /classifiedsmy.php?PostAd=1?;
rewrite ^/ads/cat/([^/.]+)/?$ /classifieds.php?catUri=$1?;
rewrite ^/ads/all/cat/(\d+)/(\d+)/([^/.]+)/?$ /classifieds.php?catUri=$3&page=$2&per_page=$1?;
rewrite ^/ads/subcat/([^/.]+)/?$ /classifieds.php?scatUri=$1?;
rewrite ^/ads/all/subcat/(\d+)/(\d+)/([^/.]+)/?$ /classifieds.php?scatUri=$3&page=$2&per_page=$1?;
rewrite ^/ads/entry/([^/.]+)/?$ /classifieds.php?entryUri=$1?;
rewrite ^/ads/tag/([^/.]+)/?$ /classifieds_tags.php?tag=$1?;
}

location /photo/ {
rewrite ^/photo/all/(\d+)/(\d+)/?$ /browsePhoto.php?page=$2&per_page=$1?;
rewrite ^/photo/gallery_top/?$ /browsePhoto.php?rate=top?;
rewrite ^/photo/gallery_top/(\d+)/(\d+)/?$ /browsePhoto.php?rate=top&page=$2&per_page=$1?;
rewrite ^/photo/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$ /browsePhoto.php?tag=$1&page=$3&per_page=$2?;
rewrite ^/photo/gallery_tag/([^/.]+)/?$ /browsePhoto.php?tag=$1?;
rewrite ^/photo/gallery/all/([^/.]+)/(\d+)/(\d+)/?$ /browsePhoto.php?ownerName=$1&page=$3&per_page=$2?;
rewrite ^/photo/gallery/all/([^/.]+)/?$ /browsePhoto.php?ownerName=$1?;
rewrite ^/photo/gallery/([^/.]+)/?$ /viewPhoto.php?fileUri=$1?;
rewrite ^/photo/gallery/?$ /viewPhoto.php?fileUri=$1?;
}

location /music/ {
rewrite ^/music/all/(\d+)/(\d+)/?$ /browseMusic.php?page=$2&per_page=$1?;
rewrite ^/music/gallery_top/?$ /browseMusic.php?rate=top?;
rewrite ^/music/gallery_top/(\d+)/(\d+)/?$ /browseMusic.php?rate=top&page=$2&per_page=$1?;
rewrite ^/music/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$ /browseMusic.php?tag=$1&page=$3&per_page=$2?;
rewrite ^/music/gallery_tag/([^/.]+)/?$ /browseMusic.php?tag=$1?;
rewrite ^/music/gallery/all/([^/.]+)/(\d+)/(\d+)/?$ /browseMusic.php?ownerName=$1&page=$3&per_page=$2?;
rewrite ^/music/gallery/all/([^/.]+)/?$ /browseMusic.php?ownerName=$1?;
rewrite ^/music/gallery/([^/.]+)/?$ /viewMusic.php?fileUri=$1?;
rewrite ^/music/gallery/?$ /viewMusic.php?fileUri=$1?;
}

location /video/ {
rewrite ^/video/all/(\d+)/(\d+)/?$ /browseVideo.php?page=$2&per_page=$1?;
rewrite ^/video/gallery_top/?$ /browseVideo.php?rate=top?;
rewrite ^/video/gallery_top/(\d+)/(\d+)/?$ /browseVideo.php?rate=top&page=$2&per_page=$1?;
rewrite ^/video/gallery_tag/([^/.]+)/(\d+)/(\d+)/?$ /browseVideo.php?tag=$1&page=$3&per_page=$2?;
rewrite ^/video/gallery_tag/([^/.]+)/?$ /browseVideo.php?tag=$1?;
rewrite ^/video/gallery/all/([^/.]+)/(\d+)/(\d+)/?$ /browseVideo.php?ownerName=$1&page=$3&per_page=$2?;
rewrite ^/video/gallery/all/([^/.]+)/?$ /browseVideo.php?ownerName=$1?;
rewrite ^/video/gallery/([^/.]+)/?$ /viewVideo.php?fileUri=$1?;
rewrite ^/video/gallery/?$ /viewVideo.php?fileUri=$1?;
}

location /groups/ {
rewrite ^/groups/all/?$ /grp.php;
rewrite ^/groups/entry/([^/.]+)/?$ /grp.php?action=group&groupUri=$1?;
rewrite ^/groups/category/([^/.]+)/?$ /grp.php?action=categ&categUri=$1?;
rewrite ^/groups/keyword/([^/.]+)/?$ /grp.php?action=categ&keyword=$1?;
}

location /search/tag/ {
rewrite ^/search/tag/([^/.]+)/?$ /search.php?Tags=$1?;
}

location / {
try_files $uri $uri/ /profile.php?ID=$uri;
}
--------------------------

>
> RewriteCond %{REQUEST_FILENAME} -f [OR]
> RewriteCond %{REQUEST_FILENAME} -d
> RewriteRule .+ - [L]
> RewriteRule ^([A-Za-z0-9_-]+)$ profile.php?ID=$1 [QSA,L]
>
Those here could be done with a try rule. Something like:
--------------------------
location / {
try_files $uri $uri/ /profile.php?ID=$uri;
}
--------------------------

Or:
--------------------------
location / {
if (-e $request_filename) {
set $ampr01 1;
}
if ($request_filename ~* "^([A-Za-z0-9_-]+)$") {
set $ampr02 1;
}
if ($ampr01$ampr02 = "11") {
rewrite ^/([A-Za-z0-9_-]+)$ /profile.php?ID=$1 last;
break;
}
}
--------------------------


I have not tested those rules. I don't know if they work.


> Regards,
>
Kind Regards,

> -Team AMP
>
Steve


> http://www.ampprod.com
>

--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx