python - 在 ubuntu 服务器上,nginx 无法提供跨域图像 url
问题描述
我已经使用 Django 框架开发项目并从http://data.myothersite.org/data/images/agents/A_1747.jpg获取图像文件
在本地主机中,我已经测试并能够在我的列表页面中获取所有图像,但是在具有域的实时服务器上,http://www.myfirstsite.org
我无法获取托管的所有图像http://data.myothersite.org
并获得权限被拒绝错误。
我试图add_header Access-Control-Allow-Origin
在 nginx conf 文件中设置 http://data.myothersite.org/` 但没有任何运气。
我也尝试在网上找到解决方案,但无法找到。
谢谢。
解决方案
由于http://www.myfirstsite.org
要从加载图像http://data.myothersite.org
,因此必须在 nginx conf 中提供权限,http://data.myothersite.org
而不是在 nginx conf 中http://www.myfirstsite.org
在 nginx conf 中提供此标头http://data.myothersite.org
add_header 'Access-Control-Allow-Origin' 'http://www.myfirstsite.org' always;
推荐阅读
- r - R:如何按组计算列的前几行的最大值?
- python - 除非我手动停止程序,否则为什么 Speech_recgonition 永远不会停止?
- powershell - 如何从 PowerShell GUI 获取文件名
- java - 使用 spring-boot-starter-data-jpa 时出现 Hibernate-core 错误
- c++ - C ++ fstream:get()跳过第一行和最后一行
- sql - 对表/视图中的所有列进行排名
- android - Lollipop 中的进度条颜色不一致
- python - 我们如何从 Google 表格中读取 Python 中的 DF?
- assembly - 为什么基指针指向栈顶?
- javascript - ThreeJS 在形状边缘添加 45 度切割