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.

How would one set the root path of an nginx server to a direcoty outside the ngnix folder?

Currently ngnix is here: c:/ngnix

I would like c:/www to be the root.

currently with server { listen 80; server_name localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;
    root  c:/www;
    location / {
        index  index.html index.htm;
        autoindex on;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
share|improve this question
1  
You already have exactly what you want in the piece of config you have pasted there. The only case it won't use c:/www is when the URI /50x.html is triggered as you overwrite the root there. –  Martin Fjordvald Jul 27 '11 at 7:59
add comment

1 Answer

The root option could be inside the location block. Try:

    location / {
        root   c:/www;
        index  index.html index.htm;
    }
share|improve this answer
1  
Sorry this is not true. Directives should whenever possible be placed in the highest possible context as they inherit down. If placed in location / it is only available in location / not in any other locations. –  Martin Fjordvald Jul 27 '11 at 7:58
    
I was referring to his specific example. In fact, this is the syntax in the example nginx.conf file – I only modified the root line. But you are correct in that his original config works (I tested it just now). –  fission Jul 27 '11 at 8:00
1  
In this specific example it makes no sense either. The example nginx.conf file provided with the source install is actually a really bad example and the examples on the nginx wiki should be followed instead. –  Martin Fjordvald Jul 27 '11 at 9:10
    
Interesting – I had no idea! That is good to know, and I'm glad it was captured here as well for posterity. Thanks. –  fission Jul 27 '11 at 9:37
add comment

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.