# ROS-SDK 100%内网转发配置

此配置会将前端静态资源、地图资源、服务接口资源都会进行转发

# 1.ros-sdk文档

https://www.yuque.com/liuwenzhu-yvbcw/ztu9g9/lwvhzz?singleDoc# (opens new window) 《ROS-SDK对外文档》

# 2.可以将ros-sdk的js下载到本地使用(本地开发下如果可以访问npm,前端也可使用npm安装)

# 3.配置资源请求内网地址

const rosSdk = new window.BAIDU_ROS_SDK({
  // ...其他配置参考ros-sdk文档,文档链接在本文最顶端
  _baseUrl: "http://您的内网地址/logisticsWeb-intranet", // 固定写法其他配置参考sdk文档
});
1
2
3
4

# 4.内网机器配置转发外网,以nginx配置为例

    # 内网转发-ros服务请求-start
    location /ros/ {
            proxy_pass   https://api.map.baidu.com/ros/;
            proxy_set_header  Host  api.map.baidu.com;
    }
     # 内网转发-前端页面请求-start
    location /logisticsWeb-intranet/ {
            proxy_pass   https://api.map.baidu.com/logisticsWeb-intranet/;
            proxy_set_header  Host  api.map.baidu.com;
    }
     # 内网地图请求转发-start
    location /logisticsWeb-intranet/api_map_baidu_com/ {
            proxy_pass   https://api.map.baidu.com/;
            proxy_set_header  Host  api.map.baidu.com;
    }
    location /logisticsWeb-intranet/webmap0_bdimg_com/ {
            proxy_pass   https://webmap0.bdimg.com/;
            proxy_set_header  Host  webmap0.bdimg.com;
    }
    location /logisticsWeb-intranet/maponline0_bdimg_com/ {
            proxy_pass   https://maponline0.bdimg.com/;
            proxy_set_header  Host  maponline0.bdimg.com;
    }
    location /logisticsWeb-intranet/maponline1_bdimg_com/ {
            proxy_pass   https://maponline1.bdimg.com/;
            proxy_set_header  Host  maponline1.bdimg.com;
    }
    location /logisticsWeb-intranet/maponline2_bdimg_com/ {
            proxy_pass   https://maponline2.bdimg.com/;
            proxy_set_header  Host  maponline2.bdimg.com;
    }
    location /logisticsWeb-intranet/maponline3_bdimg_com/ {
            proxy_pass   https://maponline3.bdimg.com/;
            proxy_set_header  Host  maponline3.bdimg.com;
    }
    location /logisticsWeb-intranet/pcor_baidu_com/ {
            proxy_pass   https://pcor.baidu.com/;
            proxy_set_header  Host  pcor.baidu.com;
    }
    location /logisticsWeb-intranet/dlswbr_baidu_com/ {
            proxy_pass   https://dlswbr.baidu.com/;
            proxy_set_header  Host  dlswbr.baidu.com;
    }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

# 5.内网机器需要访问外网服务的白名单,共8个

https://api.map.baidu.com
https://webmap0.bdimg.com
https://maponline0.bdimg.com
https://maponline1.bdimg.com
https://maponline2.bdimg.com
https://maponline3.bdimg.com
https://pcor.baidu.com
https://dlswbr.baidu.com
1
2
3
4
5
6
7
8