I'm using the official windows version of nginx. I want to specify the windows equivalent of this configuration

location /static/ {
   alias /home/user/staticfiles/;
}

How do I specify windows file paths in the alias directive? Is this even possible?

link|improve this question
feedback

2 Answers

You can try this:

  1. copy your static files into nginx/html/staticfiles
  2. set into nginx.conf

    location /static/ { alias /nginx/html/staticfiles/; }

link|improve this answer
feedback

If you try to specify an absolute path like...

location / {
    alias C:\Users\SomeUser\mysite\static;
}

...then upon requesting a file from that location, you'll probably see errors in C:\nginx\logs\error.log like:

2011/11/11 12:53:16 [error] 6236#0: *1 open() "/cygdrive/c/nginx/C:\Users\SomeUser\mysite\static\somefile.css

When configuring nginx on Windows, specify any paths relative to the C:\nginx directory. This works:

location / {
    alias ../Users/SomeUser/mysite/static;
}

Personally, I was happy to learn this because it makes my nginx configurations a little more portable between Windows and Linux than I had expected them to be. To turn a Linux configuration file into one that works on Windows, for me it's basically just:

s|/home/myname/|../Users/Myname|
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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