Forum: NGINX Rewritemap in nginx

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
562c499a4bcfb91e1d55aadc162e6f1b?d=identicon&s=25 Klaas Naaijkens (Guest)
on 2008-10-03 21:07
(Received via mailing list)
I am trying to implement the RewriteMap funcionality I am using
extensively in apache in some way with nginx.

In apache we use a dbm database where we store legacy urls (around
100.000) that we redirect to their new urls.

We have
RewriteMap oldlinks dbm:/etc/apache2/oldlinks.dbm
RewriteCond %{REQUEST_URI}                  \.php$
                 [NC]
RewriteCond %{HTTP_HOST}                    ^(www)?([^.]+)\.
                [NC]
RewriteCond ${lowercase:%2}$1               ^(.*)$
RewriteCond ${oldlinks:%1|NONE}             ^(http://.*)$
RewriteRule ^(.*php)$                       %1
                 [NC,R=301,L]

Now I am trying to reimplement this functionality in the nginx. I have
tried to create a text file with my mappings and use
NginxHttpMapModule but so far without success.

I get these messages
Starting nginx: 2008/10/03 20:31:58 [emerg] 22017#0: could not build
the map_hash, you should increase either map_hash_max_size: 102400 or
map_hash_bucket_size: 128
I can keep increase the sizes but at a certain point nginx doesn't
even start up any more.

Are there other options here?

Klaas Naaijkens
15fc40290c76b33850cc13438566b072?d=identicon&s=25 Robert Gabriel (jinx)
on 2008-10-03 22:07
Which version of nginx are u using?
562c499a4bcfb91e1d55aadc162e6f1b?d=identicon&s=25 Klaas Naaijkens (Guest)
on 2008-10-03 22:24
(Received via mailing list)
I have tried 0.7.17 and 0.5.37
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2008-10-03 22:55
(Received via mailing list)
On Fri, Oct 03, 2008 at 08:52:48PM +0200, Klaas Naaijkens wrote:

> RewriteCond %{HTTP_HOST}                    ^(www)?([^.]+)\.
> I get these messages
> Starting nginx: 2008/10/03 20:31:58 [emerg] 22017#0: could not build
> the map_hash, you should increase either map_hash_max_size: 102400 or
> map_hash_bucket_size: 128
> I can keep increase the sizes but at a certain point nginx doesn't
> even start up any more.

It seems that nginx starts, but run too long. What does top show at
start ?

You may try

http {
    map_hash_bucket_size  1024;
    map_hash_max_size     102400;
562c499a4bcfb91e1d55aadc162e6f1b?d=identicon&s=25 Klaas Naaijkens (Guest)
on 2008-10-04 09:33
(Received via mailing list)
Yes, it got to 99% CPU before and it kept there for some time.

With map_hash_bucket_size 1024 it works fine now. I had increased
bucket_size before but I hadn't realized I had to keep doubling it.

Thank you for your help.
This topic is locked and can not be replied to.