django - 404 关于在 Django 应用程序中使用 Azure 存储
问题描述
我正在尝试在 Microsoft Azure 上部署 Django 应用程序。
我在Azure 虚拟机上使用 nginx + gunicorn 。为了提供静态和媒体文件,我决定使用Azure Storage中可用的Azure Blob。
我正在使用以下库在我的应用程序中集成 Markdown + MathJax 编辑器 - django-mdeditor。
现在,这个库带有自己的JS
和CSS
文件。在以下情况下使用这个库我没有问题 -
- 地方发展。
- 在 Heroku 上部署(生产)。
- 使用 nginx + gunicorn(生产)在 Azure 虚拟机上部署。在这种情况下,我正在使用各种教程中提到的 nginx 提供静态文件,例如这个。
但是,一旦我转移到 Azure 存储作为我的存储后端。我收到以下错误 -
Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)
codemirror.min.js:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)
codemirror.min.css:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)
dialog.css:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)
codemirror.min.css:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)
matchesonscrollbar.css:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)
dialog.css:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)
除了以上几个文件,其余的静态文件都被正确抓取了!
经过进一步调查,我发现上述所有文件都是从以下脚本中获取的 - https://github.com/pylixm/django-mdeditor/blob/master/mdeditor/static/mdeditor/js/editormd.js# L549
即来自以下代码块 -
.
.
editormd.loadCSS(loadPath + "codemirror/codemirror.min");
.
.
loadPath
已settings.path
在脚本中分配等于 (afaik) 的值'./lib/'
。
loadCSS()
正在尝试从 url 获取文件 -https://edumate.blob.core.windows.net/static/mdeditor/js/libcodemirror/codemirror.min.js
而不是https://edumate.blob.core.windows.net/static/mdeditor/js/lib/codemirror/codemirror.min.js
.
请注意在第一种情况下缺少/
after 。lib
生成的 URL.../libcodemirror/..
不是../lib/codemirror/..
!
使用或方法获取的所有其他文件也是如此,JS
如上所示。CSS
loadCSS()
loadScript()
奇怪的是,这种删除/
只会在使用 Azure 存储时发生,而不是在使用 Heroku、nginx + gunicorn 或开发服务器时发生。
关于如何调试的任何想法?
解决方案
推荐阅读
- http - ChunkedWriteHandler 与 HttpObjectAggregator?
- javascript - 使用 AngularJS 从 Excel 导入
- asp.net - 为 asp:content 设置 100% 的高度和宽度
- regex - 正则表达式:以特定字符结尾的完全匹配字符串
- android - 与霍尼韦尔水槽集成,未经许可的SecurityException DecodeService
- javascript - HTML 图像标记未呈现正确分配给标题属性的表格
- airflow - 将变量传递给 Airflow 中的模板
- vba - 从字符串中获取除最后一个单词之外的所有单词
- influxdb - 带有分组数据的 grafana 的 influxdb 查询
- javascript - 我可以在 for 循环中执行“onClick”功能吗?