Answer the question
In order to leave comments, you need to log in
How to specify root and alias paths in Nginx?
The server has a site root directory, and it has nested static and media subdirectories, which should be opened directly through Nginx.
var
|__ www
|__ domains
|__ example.com
|__ django-app
|__ static
|__ media
server {
...
location /static {
root /var/www/domains/example.com/static;
}
location /media {
root /var/www/domains/example.com/media;
}
}
server {
...
root /var/www/domains/example.com
...
location /static {
alias /static;
}
location /media {
alias /media;
}
}
Answer the question
In order to leave comments, you need to log in
Both options are wrong.
In the first option, the request /static/file.png
will look for a file
/var/www/domains/example.com/static/static/file.png
. /static/file.png
will look for a /static/file.png
. server {
...
root /var/www/domains/example.com;
...
location /static/ {
}
location /media/ {
}
}
/mediaholding/about
is trying to find the file, and not to be proxied in django.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question