I'm pretty new to nginx configs. I'm having some difficulty with a pretty basic problem. I'd like to host some static files at /doc (index.html, some images, etc). The files are located in a directory called /sites/mysite/proj/doc/. The problem is, is that with the nginx config below, nginx tries to look for a directory called "/sites/mysite/proj/doc/doc". Perhaps this can be fixed by setting the root to /sites/mysite/proj/, but I don't want to potentially expose other (non-static) assets in the proj/ directory. And for various reasons, I can't really move the doc/ directory from where it is.
I think there is a way to use a Rewrite rule to solve this situation, but I don't really understand all the parts, so having some difficulty formulating the rule.
rewrite ^/doc/(.*)$ /$1 permanent;
I've also included a working example of hosting files out of a /sites/mysite/htdocs/static/ directory.
> vim locations.conf
location /static {
root /sites/mysite/htdocs/;
access_log off;
autoindex on;
}
location /doc {
root /sites/mysite/proj/doc/;
access_log on;
autoindex on;
}
2011/11/19 23:49:00 [error] 2314#0: *42 open() "/sites/mysite/proj/doc/doc" failed (2: No such file or directory), client: 100.100.100.100, server: , request: "GET /doc HTTP/1.1", host: "myhost.com"
Does anyone have any ideas how I might go about serving this static content?
Any help is much appreciated.
Thanks,
Joe