Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I recently have 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) and see if PHP + Postgres access work.

Now I want to learn how rewriting URLs work 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>;
            }

[...]

share|improve this question

2 Answers 2

up vote 1 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:

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.

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

 
discard

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.