# 在内网访问高德地图

在一些安全要求较高的内网环境,浏览器可能被禁止访问互联网,导致地图无法正常展示。此时,可以在内网部署一台代理服务器(下文简称为“GIS代理服务器”),GIS代理服务器只把互联网上的GIS地图服务代理到内网来。下面以代理互联网上的高德地图(https://gaode.com/)为例,说明如何配置内网GIS代理服务器。

GIS代理服务访问高德地址 GIS代理服务器本机需监听的端口
{vdata,vdata01,vdata02,vdata03,vdata04}.amap.com 8123
{glyph,glyph01,glyph02,glyph03,glyph04}.amap.com 200,200{1,4}
{sdf,sdf01,sdf02,sdf03,sdf04}.amap.com 300,300{1,4}
{webrd01,webrd02,webrd03,webrd04}.is.autonavi.com 820{1,4}
{wprd01,wprd02,wprd03,wprd04}.is.autonavi.com 830{1,4}
{webst01,webst02,webst03,webst04}.is.autonavi.com 840{1,4}
webapi.amap.com 8121
ditu.amap.com 8122
vdata.amap.com 8123
a.amap.com 8124
restapi.amap.com 8125
cache.amap.com 8126
g.alicdn.com 8131
at.alicdn.com 8132
w.cnzz.com 8141
c.cnzz.com 8142
q14.cnzz.com 8143
pcookie.cnzz.com 8144
log.mmstat.com 8151
res.mmstat.com 8152
gm.mmstat.com 8153
cnzz.mmstat.com 8154
uri.amap.com 8119
tm.amap.com 8118
mvt.amap.com 8117

TIP

其中高德地址列表是需要GIS代理服务器开通访问这些地址的权限,本机监听的端口是开通客户端访问GIS代理服务器这些端口的权限

# 将高德服务代理到内网

# 1. 安装部署apache httpd作为反向代理服务

以Centos为例,使用yum安装:

yum -y install httpd

# 2. 修改apache配置文件/etc/httpd/conf/httpd.conf

注释默认监听端口80,并从最后一行开始增加以下行

<Location "/">
AddOutputFilterByType SUBSTITUTE;DEFLATE text/html application/javascript text/javascript text/css
SetOutputFilter INFLATE;SUBSTITUTE;DEFLATE
Substitute "s!\{vdata,vdata01,vdata02,vdata03,vdata04\}\.amap\.com!192.168.3.110:812{3}"
Substitute "s!webrd0(\{[\d\|,]+\})\.is\.autonavi\.com!192.168.3.110:820$1"
Substitute "s!wprd0(\{[\d\|,]+\})\.is\.autonavi\.com!192.168.3.110:830$1"
Substitute "s!webst0(\{[\d\|,]+\})\.is\.autonavi\.com!192.168.3.110:840$1"
Substitute "s!glyph(|0[0-9])\.amap\.com!192.168.3.110:200$1"
Substitute "s!sdf(|0[0-9])\.amap\.com!192.168.3.110:300$1"
Substitute "s|webapi\.amap\.com|192.168.3.110:8121"
Substitute "s|ditu\.amap\.com|192.168.3.110:8122"
Substitute "s|vdata\.amap\.com|192.168.3.110:8123"
Substitute "s|a\.amap\.com|192.168.3.110:8124"
Substitute "s|restapi\.amap\.com|192.168.3.110:8125"
Substitute "s|cache\.amap\.com|192.168.3.110:8126"
Substitute "s|g\.alicdn\.com|192.168.3.110:8131"
Substitute "s|at\.alicdn\.com|192.168.3.110:8132"
Substitute "s|w\.cnzz\.com|192.168.3.110:8141"
Substitute "s|c\.cnzz\.com|192.168.3.110:8142"
Substitute "s|q14\.cnzz\.com|192.168.3.110:8143"
Substitute "s|http\://pcookie\.cnzz\.com|http\://192.168.3.110:8144"
Substitute "s|https\://log\.mmstat\.com|http\://192.168.3.110:9443"
Substitute "s|log\.mmstat\.com|192.168.3.110:8151"
Substitute "s|res\.mmstat\.com|192.168.3.110:8152"
Substitute "s|gm\.mmstat\.com|192.168.3.110:8153"
Substitute "s|cnzz\.mmstat\.com|192.168.3.110:8154"
Substitute "s|uri\.amap\.com|192.168.3.110:8119"
Substitute "s|tm\.amap\.com|192.168.3.110:8118"
Substitute "s|mvt\.amap\.com|192.168.3.110:8117"
Substitute "s|https|http"
</Location>
Listen 300
<VirtualHost *:300>
ProxyPass / http://sdf.amap.com/
ProxyPassReverse / http://sdf.amap.com/
</VirtualHost>
Listen 30001
<VirtualHost *:30001>
ProxyPass / http://sdf01.amap.com/
ProxyPassReverse / http://sdf01.amap.com/
</VirtualHost>
Listen 30002
<VirtualHost *:30002>
ProxyPass / http://sdf02.amap.com/
ProxyPassReverse / http://sdf02.amap.com/
</VirtualHost>
Listen 30003
<VirtualHost *:30003>
ProxyPass / http://sdf03.amap.com/
ProxyPassReverse / http://sdf03.amap.com/
</VirtualHost>
Listen 30004
<VirtualHost *:30004>
ProxyPass / http://sdf04.amap.com/
ProxyPassReverse / http://sdf04.amap.com/
</VirtualHost>
Listen 200
<VirtualHost *:200>
ProxyPass / http://glyph.amap.com/
ProxyPassReverse / http://glyph.amap.com/
</VirtualHost>
Listen 20001
<VirtualHost *:20001>
ProxyPass / http://glyph01.amap.com/
ProxyPassReverse / http://glyph01.amap.com/
</VirtualHost>
Listen 20002
<VirtualHost *:20002>
ProxyPass / http://glyph02.amap.com/
ProxyPassReverse / http://glyph02.amap.com/
</VirtualHost>
Listen 20003
<VirtualHost *:20003>
ProxyPass / http://glyph03.amap.com/
ProxyPassReverse / http://glyph03.amap.com/
</VirtualHost>
Listen 20004
<VirtualHost *:20004>
ProxyPass / http://glyph04.amap.com/
ProxyPassReverse / http://glyph04.amap.com/
</VirtualHost>
Listen 8119
<VirtualHost *:8119>
ProxyPass / http://uri.amap.com/
ProxyPassReverse / http://uri.amap.com/
</VirtualHost>
Listen 8118
<VirtualHost *:8118>
ProxyPass / http://tm.amap.com/
ProxyPassReverse / http://tm.amap.com/
</VirtualHost>
Listen 8117
<VirtualHost *:8117>
ProxyPass / http://mvt.amap.com/
ProxyPassReverse / http://mvt.amap.com/
</VirtualHost>
Listen 8121
<VirtualHost *:8121>
ProxyPass / http://webapi.amap.com/
ProxyPassReverse / http://webapi.amap.com/
</VirtualHost>
Listen 8122
<VirtualHost *:8122>
ProxyPass / http://ditu.amap.com/
ProxyPassReverse / http://ditu.amap.com/
</VirtualHost>
Listen 8123
<VirtualHost *:8123>
ProxyPass / http://vdata.amap.com/
ProxyPassReverse / http://vdata.amap.com/
</VirtualHost>
Listen 8124
<VirtualHost *:8124>
ProxyPass / http://a.amap.com/
ProxyPassReverse / http://a.amap.com/
</VirtualHost>
Listen 8125
<VirtualHost *:8125>
ProxyPass / http://restapi.amap.com/
ProxyPassReverse / http://restapi.amap.com/
</VirtualHost>
Listen 8126
<VirtualHost *:8126>
ProxyPass / http://cache.amap.com/
ProxyPassReverse / http://cache.amap.com/
</VirtualHost>
Listen 8127
<VirtualHost *:8127>
ProxyPass / http://140.205.177.57/
ProxyPassReverse / http://140.205.177.57/
</VirtualHost>
Listen 8131
<VirtualHost *:8131>
ProxyPass / http://g.alicdn.com/
ProxyPassReverse / http://g.alicdn.com/
</VirtualHost>
Listen 8132
<VirtualHost *:8132>
ProxyPass / http://at.alicdn.com/
ProxyPassReverse / http://at.alicdn.com/
</VirtualHost>
Listen 8139
<VirtualHost *:8139>
ProxyPass / http://140.205.177.57/
ProxyPassReverse / http://140.205.177.57/
</VirtualHost>
Listen 8141
<VirtualHost *:8141>
ProxyPass / http://w.cnzz.com/
ProxyPassReverse / http://w.cnzz.com/
</VirtualHost>
Listen 8142
<VirtualHost *:8142>
ProxyPass / http://c.cnzz.com/
ProxyPassReverse / http://c.cnzz.com/
</VirtualHost>
Listen 8143
<VirtualHost *:8143>
ProxyPass / http://q14.cnzz.com/
ProxyPassReverse / http://q14.cnzz.com/
</VirtualHost>
Listen 8144
<VirtualHost *:8144>
ProxyPass / http://pcookie.cnzz.com/
ProxyPassReverse / http://pcookie.cnzz.com/
</VirtualHost>
Listen 9443
<VirtualHost *:9443>
ProxyPass / http://log.mmstat.com/
ProxyPassReverse / http://log.mmstat.com/
</VirtualHost>
Listen 8151
<VirtualHost *:8151>
ProxyPass / http://log.mmstat.com/
ProxyPassReverse / http://log.mmstat.com/
</VirtualHost>
Listen 8152
<VirtualHost *:8152>
ProxyPass / http://res.mmstat.com/
ProxyPassReverse / http://res.mmstat.com/
</VirtualHost>
Listen 8153
<VirtualHost *:8153>
ProxyPass / http://gm.mmstat.com/
ProxyPassReverse / http://gm.mmstat.com/
</VirtualHost>
Listen 8154
<VirtualHost *:8154>
ProxyPass / http://cnzz.mmstat.com/
ProxyPassReverse / http://cnzz.mmstat.com/
</VirtualHost>
Listen 8201
<VirtualHost *:8201>
ProxyPass / http://webrd01.is.autonavi.com/
ProxyPassReverse / http://webrd01.is.autonavi.com/
</VirtualHost>
Listen 8202
<VirtualHost *:8202>
ProxyPass / http://webrd02.is.autonavi.com/
ProxyPassReverse / http://webrd02.is.autonavi.com/
</VirtualHost>
Listen 8203
<VirtualHost *:8203>
ProxyPass / http://webrd03.is.autonavi.com/
ProxyPassReverse / http://webrd03.is.autonavi.com/
</VirtualHost>
Listen 8204
<VirtualHost *:8204>
ProxyPass / http://webrd04.is.autonavi.com/
ProxyPassReverse / http://webrd04.is.autonavi.com/
</VirtualHost>
Listen 8301
<VirtualHost *:8301>
ProxyPass / http://wprd01.is.autonavi.com/
ProxyPassReverse / http://wprd01.is.autonavi.com/
</VirtualHost>
Listen 8302
<VirtualHost *:8302>
ProxyPass / http://wprd02.is.autonavi.com/
ProxyPassReverse / http://wprd02.is.autonavi.com/
</VirtualHost>
Listen 8303
<VirtualHost *:8303>
ProxyPass / http://wprd03.is.autonavi.com/
ProxyPassReverse / http://wprd03.is.autonavi.com/
</VirtualHost>
Listen 8304
<VirtualHost *:8304>
ProxyPass / http://wprd04.is.autonavi.com/
ProxyPassReverse / http://wprd04.is.autonavi.com/
</VirtualHost>
Listen 8401
<VirtualHost *:8401>
ProxyPass / http://webst01.bis.autonavi.com/
ProxyPassReverse / http://webst01.is.autonavi.com/
</VirtualHost>
Listen 8402
<VirtualHost *:8402>
ProxyPass / http://webst02.is.autonavi.com/
ProxyPassReverse / http://webst02.is.autonavi.com/
</VirtualHost>
Listen 8403
<VirtualHost *:8403>
ProxyPass / http://webst03.is.autonavi.com/
ProxyPassReverse / http://webst03.is.autonavi.com/
</VirtualHost>
Listen 8404
<VirtualHost *:8404>
ProxyPass / http://webst04.is.autonavi.com/
ProxyPassReverse / http://webst04.is.autonavi.com/
</VirtualHost>

# 3.启动apache httpd服务并验证接口正常访问

在服务器上使用curl命令测试高德接口以及本地监听响应是否一致

service httpd start
curl restapi.amap.com
curl 127.0.0.1:8125

# 设置高德服务器内网地址

高德服务器内网地址配置参见内网代理

是否有帮助?
0条评论
评论