Using Nginx with Django, I have the following location entry in my server config:
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:1234;
}
Thus, all root URL requests are passed to Django.
Now, I'd like to serve some additional files, such as robots.txt
, favicon.ico
, and an indefinite number of other files, under the root URL as well. For example /robots.txt
should return my robots.txt
file, which lives in /var/www/project/misc/
. How do I do this in Nginx? I can't seem to have several locations for capturing the root URL "/".
I know, I can do it like this:
location /robots.txt {
alias /var/www/project/misc/robots.txt;
}
However, we're talking about a lot of different files, and adding an extra location for all of them seems to be rather clumsy. It would be better if there was a way for simply serving a whole directory under the root URL.
Just break out application into it's own @special location, then try the filesystem first.