参考:https://q.cnblogs.com/q/103812/
Flask中关于url_for()的坑:https://blog.youkuaiyun.com/yannanxiu/article/details/52287870
需要flask返回服务器上静态文件的url地址:
return url_for('static', _external=True, filename='images/99c5.jpg')
但是在客户端得到的地址为,http://172.168.xx.xx/static/images/99c5.jpg
在浏览器上访问得到的是 404. 缺少端口号(我设置的端口号为86)。
解决方法:
在nginx的配置文件 /etc/nginx/conf.d/wsgi.conf 中,将:
proxy_set_header Host $host;
更改为:
proxy_set_header Host $host:86;
此时得到的图片url为:http://172.168.xx.xx:86/static/images/99c5.jpg