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

Here is the error we have when loading nginx on ubuntu 12.04 server:

nginx: [emerg] invalid number of arguments in "location" directive in /opt/nginx/conf/nginx.conf:58

What we are trying to do is to append a string to the end of uri entered. For example, if or are entered, nginx should rewrite them to

Here is what we have in nginx.conf:

location {
          rewrite "/[a-zA-Z]\w{1,9}/" /$1/auth/signin last;
          rewrite "/[a-zA-Z]\w{1,9}" /$1/auth/signin last;

What's wrong with the location block above and how we should name the location block? Thanks for the help.


Here is server block in nginx.conf:

 server {
        listen 80;
        root /var/www/;
        passenger_enabled on;
        rails_env production;
        passenger_base_uri /nbhy;

share|improve this question
up vote 1 down vote accepted

A location block needs a uri. So, you may want this:

location / {
    rewrite "/[a-zA-Z]\w{1,9}/" /$1/auth/signin last;
    rewrite "/[a-zA-Z]\w{1,9}" /$1/auth/signin last;

Or, if you don't want to apply these rewrites to a certain path, just remove the location part altogether. I.e.

rewrite "/[a-zA-Z]\w{1,9}/" /$1/auth/signin last;
rewrite "/[a-zA-Z]\w{1,9}" /$1/auth/signin last;
share|improve this answer
What's the uri for the location block? Does it mean anything? – user938363 Jun 9 '13 at 23:03
Now the nginx error disappeared. But there is an 500 error with There is no change on the url displayed in browser. Firebug did not show what's the uri it rewrote. – user938363 Jun 9 '13 at 23:12

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.