Nginx 和 flask 静态目录 - CSS 链接不正确
Nginx and flask static directory - CSS not linking correctly
这是我的静态目录:
- /var/www/myapp/app/static/css
- /var/www/myapp/app/static/js
- /var/www/myapp/app/static/img
在我的 nginx 配置中我有这个:
location /static {
alias /var/www/myapp/app/static;
expires 30d;
access_log off;
}
然后在我的模板中使用如下内容:
<img height="60" src="{{url_for('static', filename='img/logo.jpg')}}"></img>
但是,它不呈现。当我在 Flask 下查看 HTML 页面 运行 的源代码时,它呈现如下:
<img height="60" src="/static/img/logo.jpg">
我在这里做错了什么?
nginx_server.conf 例子
root /var/www/website/;
# make path root + location `name` = root + /static/ = real path
location /static/ {
alias /var/www/website/static/;
expires 30d;
}
尽情享受吧。
这是我的静态目录:
- /var/www/myapp/app/static/css
- /var/www/myapp/app/static/js
- /var/www/myapp/app/static/img
在我的 nginx 配置中我有这个:
location /static {
alias /var/www/myapp/app/static;
expires 30d;
access_log off;
}
然后在我的模板中使用如下内容:
<img height="60" src="{{url_for('static', filename='img/logo.jpg')}}"></img>
但是,它不呈现。当我在 Flask 下查看 HTML 页面 运行 的源代码时,它呈现如下:
<img height="60" src="/static/img/logo.jpg">
我在这里做错了什么?
nginx_server.conf 例子
root /var/www/website/;
# make path root + location `name` = root + /static/ = real path
location /static/ {
alias /var/www/website/static/;
expires 30d;
}
尽情享受吧。