Rewritemap in nginx

Klaas Naaijkens klaas.naaijkens at gmail.com
Fri Oct 3 22:52:48 MSD 2008


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





More information about the nginx mailing list