How to point static folder in Nginx for a Django application
Solution 1:
You need to have following server
config:
server {
listen 80;
server_name 127.0.0.1;
location ~ /portal(?<djangouri>.*) {
alias /home/ubuntu/en/static;
try_files $uri $uri/ @django;
}
location @django {
include proxy_params;
proxy_pass http://localhost:8000/en$djangouri;
}
}
First location
block checks if a file exists in the path, and serves it. If no file exists, then request is passed to django.