-1

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: file structure

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?

MattE
  • 159
  • 12
  • Have you checked the `nginx-access.log` and `nginx-error.log`? I notice that you use inconsistent case, does your implementation ignore case? – Richard Smith Sep 27 '16 at 11:19
  • You accepted request on CGI but you want pushing static files with flask/nginx/etc ? You can't handle hardware buffer twice, any read/accept command will be cleared hardware buffer. – dsgdfg Sep 27 '16 at 11:33
  • 1
    Not only do you mix the case (`CSS` vs `css`), you include `../static/` in the JavaScript path. Remove that. – dirn Sep 27 '16 at 12:17
  • @dim, the your suggestion fixed for me by amending the pointer in the code as suggested... pretty dumb mistake but thanks :) If you wish to add as an answer I will mark as the answer. – MattE Sep 27 '16 at 12:29

1 Answers1

0

Not only do you mix the case (CSS vs css), you include ../static/ in the JavaScript path. Fix the capitalization and remove the ../static/.

Celeo
  • 5,583
  • 8
  • 39
  • 41