内网nginx代理高德问题
A为外网服务器
#内网调用互联网高德地图
server {
listen 8090;
large_client_header_buffers 4 128k;
client_max_body_size 100m;
client_body_buffer_size 100m;
client_header_buffer_size 100m;
client_body_timeout 60s;
location / {
proxy_pass https://webapi.amap.com; #默认/还是不配置proxy_pass比较好,我觉得
}
location /webapi/ {
proxy_pass https://webapi.amap.com/;
}
location /restapi/ {
proxy_pass https://restapi.amap.com/;
}
location /vdata/ {
proxy_pass https://vdata.amap.com/;
}
location /vdata01/ {
proxy_pass https://vdata01.amap.com/;
}
location /vdata02/ {
proxy_pass https://vdata02.amap.com/;
}
location /vdata03/ {
proxy_pass https://vdata03.amap.com/;
}
location /vdata04/ {
proxy_pass https://vdata04.amap.com/;
}
location /webst01 {
proxy_pass https://webst01.is.autonavi.com/;
}
location /webst02 {
proxy_pass https://webst02.is.autonavi.com/;
}
location /webst03 {
proxy_pass https://webst03.is.autonavi.com/;
}
location /webst04 {
proxy_pass https://webst04.is.autonavi.com/;
}
location /wprd01 {
proxy_pass https://wprd01.is.autonavi.com/;
}
location /wprd02 {
proxy_pass https://wprd02.is.autonavi.com/;
}
location /wprd03 {
proxy_pass https://wprd03.is.autonavi.com/;
}
location /wprd04 {
proxy_pass https://wprd04.is.autonavi.com/;
}
}
估计问题还是出在location匹配后面的/问题,有时间多研究研究location代理,很麻烦
内网服务器通过15.72.191.145:18090访问外网机器的8090端口
B为内网服务器
nginx配置
server {
listen 8081;
server_name 15.72.185.21;
location /webapi/ {
proxy_pass http://15.72.191.145:18090/;
}
location /restapi {
proxy_pass http://15.72.191.145:18090/restapi/;
}
location /maps { #通过sub模块修改maps自动调用高德外网的域名改为内网ip端口
proxy_set_header Accept-Encoding "";
proxy_pass http://15.72.191.145:18090/maps/;
sub_filter_types *;
sub_filter_once off;
sub_filter 'http://webapi.amap.com' 'http://15.72.191.145:18090/webapi';
sub_filter 'https://webapi.amap.com' 'http://15.72.191.145:18090/';
sub_filter 'http://restapi.amap.com' 'http://15.72.191.145:18090/restapi';
sub_filter 'http://vdata.amap.com' 'http://15.72.191.145:18090/vdata';
sub_filter 'vdata.amap.com' '15.72.191.145:18090/vdata';
sub_filter 'vdata0{1,2,3,4}.amap.com' '15.72.191.145:18090/vdata0{1,2,3,4}';
sub_filter '{vdata,vdata01,vdata02,vdata03,vdata04}.amap.com' '15.72.191.145:18090/{vdata,vdata01,vdata02,vdata03,vdata04}';
sub_filter 'webapi.amap.com/count' '15.72.191.145:18090/count';
sub_filter 'wprd0{1,2,3,4}.is.autonavi.com' '15.72.191.145:18090/wprd0{1,2,3,4}';
sub_filter 'webapi.amap.com/theme' '15.72.191.145:18090/theme';
sub_filter 'restapi.amap.com/v4' '15.72.191.145:18090/restapi/v4';
sub_filter 'webapi.amap.com/style' '15.72.191.145:18090/style';
sub_filter 'https' 'http';
}
location /vdata {
proxy_pass http://15.72.191.145:18090/vdata/;
}
location /vdata01 {
proxy_pass http://15.72.191.145:18090/vdata01/;
}
location /vdata02 {
proxy_pass http://15.72.191.145:18090/vdata02/;
}
location /vdata03 {
proxy_pass http://15.72.191.145:18090/vdata03/;
}
location /vdata04 {
proxy_pass http://15.72.191.145:18090/vdata04/;
}
}
webapi注意 / ,可能是我对nginx的location匹配规则还不熟悉,大坑,目前这么配置是能成功访问高德的
本帖子也是纯手工制作,转载请标明出处-----------burukku(づ。◕ᴗᴗ◕。)づ