I've read some documentation and tried and number of alternatives from previous answers on this site but cannot get nginx to serve my css & js files from my flask app. In my code i have for example:
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}"/>
<script type="text/javascript" src=" ../static/js/jquery.tablesorter.js"></script>
and my file structure looks like this:
In my nginx config '/etc/nginx/sites-enabled/src' I am able to get the html files within templates to serve ok and also able to get the 'log_big.png' file within the static folder to serve ok... but I cannot get the 3rd location entry to work and serve these nested files:
server {
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /templates {
alias /home/www/src/templates/; # This works ok for html files
}
location /static/ {
alias /home/www/src/static/; # This works ok for the .png file
}
location /CSS/ {
autoindex on;
root /home/www/src/static/; # This doesn't work ?
}
include /etc/nginx/mime.types;
}
Can anyone advise what I am doing wrong please?