5

I recently installed nginx 1.0.5 with php fpm, php apc and postgres. I just want to play around with nginx and learn how to configure the basic stuff. For extended testing I decided to install PHPBB3 (went well) to see if PHP + Postgres access work.

Now I want to learn how rewriting URLs works and already found out that the rewriting stuff should be written down in a location section in the nginx config.

But unfortunately nginx seems to ignore every rewriting rule I place in the config. So I am wondering if I have to somehow switch on the rewriting feature first?

nginx -V |grep rewrite shows nothing, furthermore installing nginx-extras didn't help. I just hoped that nginx-extras contained something like a rewriting module, but unfortunately this is not the case.

Searching serverfault.com and google did not help. So - what do I have to do? :\ Any help is highly appreciated.

PS: All packages were installed with apt-get install in Debian 6.

Edit: An excerpt of my nginx vhost config below:

server {
            listen 80;
            server_name domain.org www.domain.org;

            access_log /var/log/nginx/domain.access_log;
            error_log /var/log/nginx/domain.error_log;
            rewrite_log on;
            events {
                     debug_connection  <my ip>;
            }
[...]

2 Answers 2

4

rewrite module is built-in compiled. I suggest you turning on rewrite_log to see what happens.

1

I followed the instructions here on how to configure rewrite rules and they worked but it was a little confusing at first:

http://wiki.nginx.org/HttpRewriteModule#rewrite

One thing I would strongly suggest is making sure your nginx build has debug_connection:

http://wiki.nginx.org/EventsModule#debug_connection

Turning this on for your test IP and then making requests dumps the entire nginx decision process into the error log. It is absolutely the most helpful diagnostic tool I've ever used in any web server. It will tell you exactly what happened with your rewrite rule, if it didn't match or the rule was invalid, or skipped entirely. If the apt-get doesn't support debug_connection it is worth the effort(very minimal) to rebuild with it.

1
  • Thanks for your tip - unfortunately nginx can't parse the vhost config file (see my edited question above). Any ideas? Aug 30, 2011 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .