如何解决Nginx OSM 切片缓存代理与 https 上游
我有由 https://coderwall.com/p/--wgba/nginx-reverse-proxy-cache-for-openstreetmap 配置的旧的基于 nginx 的 OSM 磁贴缓存代理,但随着源磁贴服务器迁移到 HTTPS,此解决方案不再有效:421-Misdirected Request。
基于文章 https://kimsereyblog.blogspot.com/2018/07/nginx-502-bad-gateway-after-ssl-setup.html 的修复。不幸的是,经过几天的实验 - 我仍然收到 502 错误。
我的理论是根本原因是使用通配符的上游服务器 SSL 证书:*.tile.openstreetmap.org
但所有尝试使用 $http_host
、$host
、proxy_ssl_name
、{{ 1}} 在不同的组合中没有帮助:每次都是 421 或 502。
我当前的 nginx 配置是:
proxy_ssl_session_reuse
但是访问https://example.com/osm-tiles/12/2392/1188.png时还是报错:
worker_processes auto;
events {
worker_connections 768;
}
http {
access_log /etc/nginx/logs/access_log.log;
error_log /etc/nginx/logs/error_log.log;
client_max_body_size 20m;
proxy_cache_path /etc/nginx/cache levels=1:2 keys_zone=openstreetmap-backend-cache:8m max_size=500000m inactive=1000d;
proxy_temp_path /etc/nginx/cache/tmp;
proxy_ssl_trusted_certificate /etc/nginx/ca.crt;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
proxy_ssl_name *.tile.openstreetmap.org;
sendfile on;
upstream openstreetmap_backend {
server a.tile.openstreetmap.org:443;
server b.tile.openstreetmap.org:443;
server c.tile.openstreetmap.org:443;
}
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
include /etc/nginx/mime.types;
root /dist/browser/;
location ~ ^/osm-tiles/(.+) {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X_FORWARDED_PROTO http;
proxy_set_header Host $http_host;
proxy_cache openstreetmap-backend-cache;
proxy_cache_valid 200 302 365d;
proxy_cache_valid 404 1m;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass https://openstreetmap_backend/$1;
break;
}
}
}
}
主机操作系统 Ubuntu 20.04(这里处理 https),nginx 在 docker 上从 nginx:latest image 运行,ca.crt 是默认的 ubuntu 的 crt。
请帮忙。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。