nginx代理天地图配置方法
Nginx配置文件
http {
upstream tianditu_server {
server t0.tianditu.gov.cn:443 weight=1 max_fails=2 fail_timeout=30s;
server t1.tianditu.gov.cn:443 weight=1 max_fails=2 fail_timeout=30s;
server t2.tianditu.gov.cn:443 weight=1 max_fails=2 fail_timeout=30s;
server t3.tianditu.gov.cn:443 weight=1 max_fails=2 fail_timeout=30s;
server t4.tianditu.gov.cn:443 weight=1 max_fails=2 fail_timeout=30s;
server t5.tianditu.gov.cn:443 weight=1 max_fails=2 fail_timeout=30s;
server t6.tianditu.gov.cn:443 weight=1 max_fails=2 fail_timeout=30s;
server t7.tianditu.gov.cn:443 weight=1 max_fails=2 fail_timeout=30s;
}
server {
listen *:80;
server_name localhost;
location /tianditu/ {
proxy_pass https://tianditu_server/;
proxy_set_header Host t6.tianditu.gov.cn;
proxy_ssl_session_reuse off;
proxy_ssl_server_name on;
proxy_ssl_name $proxy_host;
proxy_ssl_protocols TLSv1.2;
}
}
}
常见问题
1、配置代理后,使用代理请求天地图,地图上不显示底图。
解决方法:(1)先用一个瓦片测试一下配置的代理,确认是否能正常获取到瓦片。例如:
http://localhost:80/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX=14&TILEROW=6752&TILECOL=12899&tk=天地图tk
(2)如果瓦片不能显示,则是nginx配置问题。在nginx的bin目录执行以下命令,验证nginx配置是否正确。因为nginx配置如果是错误的,nginx -s reload不会生效。
nginx -t
(3)如果nginx -t不报错,执行nginx -s reload后,仍然获取不到瓦片,则把任务管理器中的nginx进程都结束,重新双击nginx.exe启动nginx即可。
最后更新于17天前
本文由人工编写,AI优化,转载请注明原文地址: nginx代理天地图配置方法