Here is my nginx configuration:
server {
listen 80;
server_name example.com;
location /assets {
root /var/www/frappe/sites/assets;
try_files $uri $uri/ =404;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:8000;
proxy_redirect off;
}
}
I want the /assets directory to be handled by NGINX while everything else handled by the python server running on 8000. However, I still get 404 on assets directory.
What am I doing wrong? The assets directory is readable by www-data.
Best Answer
Do you get all 404s on requests to resources under
/assets
? I suspect you may want to changeroot
toalias
inlocation /assets
, becauseroot
appends the entire request path to the directory specified, which means nginx is looking for/var/www/frappe/sites/assets/assets/site.css
, for instance.