nginx - 从 URL 中的子路径提供文件返回 CORS 请求未成功
问题描述
我正在尝试通过 Web 服务器提供一些矢量图块。用于呈现主页的主要文件正确提供,但瓷砖没有,浏览器给我这个错误,我猜是因为瓷砖位于子文件夹/tiles/
中,如错误消息所示:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at
http://my.server.org:8888/tiles/12/123/456.pbf. (Reason: CORS request did not succeed).
我很确定这是我的反向代理设置中的配置问题,但我无法弄清楚,我想知道为什么考虑到以下 nginx 配置,浏览器会继续在该 URL 中打印端口号:
server {
listen 80;
listen [::]:80;
client_max_body_size 100M;
charset utf-8;
server_name my.server.org;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
include proxy_params;
add_header Access-Control-Allow-Origin http://my.server.org;
add_header Access-Control-Max-Age 3600;
add_header Access-Control-Expose-Headers Content-Length;
add_header Access-Control-Allow-Headers Range;
proxy_pass http://127.0.0.1:8888/;
}
}
另请注意,*.pbf 文件是由某些进程动态计算的,它们不存储在服务器上。使用上述 URL 方案直接在其端点提供服务。
我有没有机会通过在 nginx 配置中设置我错过的东西来简单地解决这个问题?
解决方案
推荐阅读
- python - Flask Forms + Blueprints: KeyError: 'A secret key is required to use CSRF'
- github-actions - 如何获取触发 GitHub 操作的事件类型?
- python - Pandas groupby 分别制作两列列表
- memory - 如何在 TPM 上创建内存
- python - 文本python docx左侧的图像
- python - AttributeError:“Bot”对象没有属性“add_roles”
- wordpress - WordPress后端不显示所有帖子
- reporting-services - SSRS/BIDS开发设置VS2017
- powershell - 改进 Get-ChildItem 功能
- django-models - Django 模型:具有引用外键的属性不会出现在 ListApiView 中