Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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;

            access_log /var/log/nginx/domain.access_log;
            error_log /var/log/nginx/domain.error_log;
            rewrite_log on;
            events {
                     debug_connection  <my ip>;
share|improve this question
up vote 4 down vote accepted

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

share|improve this answer

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

One thing I would strongly suggest is making sure your nginx build has 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.

share|improve this answer
Thanks for your tip - unfortunately nginx can't parse the vhost config file (see my edited question above). Any ideas? – Valentin Aug 30 '11 at 19:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.