由于 BAIDU 地图实在恶心,但是 Google 地图 api 在国内又非常不稳定,而 ditu.google.cn 这个 api 又不提供 HTTPS。在网上找了很久,反代 Google 的方法很多,但是反代 Google API 尤其是地图 API 的。之前发现了一个南阳 GDG 提供的 API 服务(
https://ditu.gdgdocs.org/maps/api/js?sensor=false ),但是仿佛最近也被盯上了,http://www.gdgny.org/ 本身已无法访问。
于是,只能自己动手丰衣足食。提供给有需要的人士使用,但是请勿滥用。。。
使用方法 Usage:
替换谷歌字体 API:
https://fonts.googleapis.com/css?family=Roboto 替换成
https://fonts.wenfan.cn/css?family=Roboto 替换谷歌地图 API:
https://maps.google.com/maps/api/js?key=YOURKEY 替换成
https://maps.wenfan.cn/maps/api/js?key=YOURKEY 详见:
https://wenfan.cn/archives/2408.wen 用自己服务器做 GMAP API 反代的方法:
1、设定
mapsapis.YOURNAME.COM 的 A 记录指向 Host IP (一定要是 mapsapis 这个 subdomain)
2、进入 etc/apache2/mods-enabled/proxy.conf
3、在 proxy.conf 设置如下:
<IfModule mod_proxy.c>
RequestHeader unset Accept-Encoding
SSLProxyEngine On
SSLProxyCheckPeerCN on
ProxyPass /g_www/
https://google.com/ ProxyPassReverse /g_www/
https://google.com/ ProxyPass /g_mts0/
https://mts0.googleapis.com/ ProxyPassReverse /g_mts0/
https://mts0.googleapis.com/ ProxyPass /g_mts1/
https://mts1.googleapis.com/ ProxyPassReverse /g_mts1/
https://mts1.googleapis.com/ ProxyPass /g_maps/
https://maps.gstatic.com/ ProxyPassReverse /g_maps/
https://maps.gstatic.com/ ProxyPass /g_csi/
https://csi.gstatic.com/ ProxyPassReverse /g_csi/
https://csi.gstatic.com/ ProxyPass /g_gmaps/
https://maps.googleapis.com/ ProxyPassReverse /g_gmaps/
https://maps.googleapis.com/ ProxyPass /g_googlemaps/
https://maps.google.com/ ProxyPassReverse /g_googlemaps/
https://maps.google.com/ ProxyPass /maps/
https://maps.googleapis.com/maps/ ProxyPassReverse /maps/
https://maps.googleapis.com/maps/ Substitute "s|mts0.googleapis.com|YOURNAME.COM/g_mts0|n"
Substitute "s|mts1.googleapis.com|YOURNAME.COM/g_mts1|n"
Substitute "s|maps.gstatic.com|YOURNAME.COM/g_maps|n"
Substitute "s|csi.gstatic.com|YOURNAME.COM/g_csi|n"
Substitute "s|maps.googleapis.com|mapsapis.YOURNAME.COM|n"
Substitute "s|maps.google.com|YOURNAME.COM/g_googlemaps|n"
Substitute "s|https://google.com|https://YOURNAME.COM/g_www|n"
FilterDeclare Substitute
FilterProvider Substitute SUBSTITUTE "%{REQUEST_URI} =~ m#^/#"
FilterChain +Substitute
</IfModule>