2016-09-27 100 views
-1

我已经阅读了一些文档,并尝试了以前在这个网站上的答案的替代数量,但无法让nginx从我的烧瓶应用程序中为我的css & js文件提供服务。在我的代码我有,例如:无法通过nginx提供嵌套的css&js文件?

​​

和我的文件结构是这样的: file structure

在我的nginx的配置“的/ etc/nginx的//src目录启用的站点 - ”我能得到模板中的html文件可以正常工作,并且还可以获取静态文件夹中的'log_big.png'文件以便服务正常...但我无法获得第三个位置条目的工作和服务这些嵌套文件:

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; 
} 
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; 
} 

任何人都可以建议我做错了请?

+0

你检查了'nginx-access.log'和'nginx-error.log'吗?我注意到你使用不一致的情况,你的实现是否忽略了大小写? –

+0

你接受了CGI的请求,但是你想用flask/nginx/etc推动静态文件?您无法处理硬件缓冲区两次,任何读取/接受命令都会清除硬件缓冲区。 – dsgdfg

+1

你不但混合使用案例('CSS'和'css'),而且在JavaScript路径中包含'../ static /'。删除。 – dirn

回答

0

您不仅混合使用案例(CSScss),还会在JavaScript路径中包含../static/。修正大写并删除../static/