nginx转发百度地图内网化
实测有效:
1.下载百度地图mapApi.js
http://api.map.baidu.com/getscript?v=1.3&key=&services=&t=20121108061854
2.在线格式化代码
3.放到项目里
4.在mapApi.js需要替换的百度请求
location /api.map.baidu.com/ {proxy_pass http://api.map.baidu.com/;} location /sapi.map.baidu.com/ {proxy_pass http://sapi.map.baidu.com/;}location /map.baidu.com/ {proxy_pass http://map.baidu.com/;}location /its.map.baidu.com/ {proxy_pass http://its.map.baidu.com/;}location /lbsyun.baidu.com/ {proxy_pass http://lbsyun.baidu.com/;}location /loc.map.baidu.com/ {proxy_pass http://loc.map.baidu.com/;}location /webmap0.map.bdimg.com/ {proxy_pass http://webmap0.map.bdimg.com/;}location /static.tieba.baidu.com/ {proxy_pass http://static.tieba.baidu.com/;}location /or.map.bdimg.com/ {proxy_pass http://or.map.bdimg.com/;}location /ss0.bdstatic.com/ {proxy_pass http://ss0.bdstatic.com/;}location /ss0.baidu.com/ {proxy_pass http://ss0.baidu.com/;}location /d0.map.baidu.com/ {proxy_pass http://d0.map.baidu.com/; }location /d1.map.baidu.com/ {proxy_pass http://d1.map.baidu.com/; } location /d2.map.baidu.com/ {proxy_pass http://d2.map.baidu.com/; }location /d3.map.baidu.com/ {proxy_pass http://d3.map.baidu.com/; }location /online0.map.bdimg.com/ {proxy_pass http://online0.map.bdimg.com/;}location /online1.map.bdimg.com/ {proxy_pass http://online1.map.bdimg.com/;}location /online2.map.bdimg.com/ {proxy_pass http://online2.map.bdimg.com/;}location /online3.map.bdimg.com/ {proxy_pass http://online3.map.bdimg.com/;}location /online4.map.bdimg.com/ {proxy_pass http://online4.map.bdimg.com/;}location /shangetu0.map.bdimg.com/ {proxy_pass http://shangetu0.map.bdimg.com/;}location /shangetu1.map.bdimg.com/ {proxy_pass http://shangetu1.map.bdimg.com/;}location /shangetu2.map.bdimg.com/ {proxy_pass http://shangetu2.map.bdimg.com/;}location /shangetu3.map.bdimg.com/ {proxy_pass http://shangetu3.map.bdimg.com/;}location /shangetu4.map.bdimg.com/ {proxy_pass http://shangetu4.map.bdimg.com/;}location /maponline0.bdimg.com/ {proxy_pass http://maponline0.bdimg.com/;}location /maponline1.bdimg.com/ {proxy_pass http://maponline1.bdimg.com/;}location /maponline2.bdimg.com/ {proxy_pass http://maponline2.bdimg.com/;}location /maponline3.bdimg.com/ {proxy_pass http://maponline3.bdimg.com/;}location /gss0.bdstatic.com/ {proxy_pass http://gss0.bdstatic.com/;}location /gsp0.baidu.com/ {proxy_pass http://gsp0.baidu.com/;}location /g0.api.map.baidu.com/ {proxy_pass http://g0.api.map.baidu.com/;}location /g1.api.map.baidu.com/ {proxy_pass http://g1.api.map.baidu.com/;}location /g2.api.map.baidu.com/ {proxy_pass http://g2.api.map.baidu.com/;}location /g3.api.map.baidu.com/ {proxy_pass http://g3.api.map.baidu.com/;}location /pcsv0.map.bdimg.com/ {proxy_pass http://pcsv0.map.bdimg.com/;}location /pcsv1.map.bdimg.com/ {proxy_pass http://pcsv1.map.bdimg.com/;}location /pcsv2.map.bdimg.com/ {proxy_pass http://pcsv2.map.bdimg.com/;}location /api0.map.bdimg.com/ {proxy_pass http://api0.map.bdimg.com/;}location /api1.map.bdimg.com/ {proxy_pass http://api1.map.bdimg.com/;}location /api2.map.bdimg.com/ {proxy_pass http://api2.map.bdimg.com/;}}
5.nginx配置文件修改
#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;
}http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;#多个项目时要适量增加client_header_buffer_size 32k;large_client_header_buffers 4 32k;server {listen 8088;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {proxy_set_header Host baidu.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://baidu.com;}location /bda {proxy_set_header Host api.map.baidu.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://api.map.baidu.com;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {# deny all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}server {listen 8091;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host api.map.baidu.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://api.map.baidu.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}
server {listen 8092;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host shangetu0.map.bdimg.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://shangetu0.map.bdimg.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}server {listen 8093;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host shangetu1.map.bdimg.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://shangetu1.map.bdimg.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}server {listen 8094;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host shangetu2.map.bdimg.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://shangetu2.map.bdimg.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}server {listen 8095;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host shangetu3.map.bdimg.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://shangetu3.map.bdimg.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}server {listen 8096;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host shangetu4.map.bdimg.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://shangetu4.map.bdimg.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}server {listen 8097;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host maponline0.bdimg.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://maponline0.bdimg.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}server {listen 8098;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host maponline1.bdimg.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://maponline1.bdimg.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}server {listen 8099;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host maponline2.bdimg.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://maponline2.bdimg.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}server {listen 9000;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host maponline3.bdimg.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://maponline3.bdimg.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}server {listen 9001;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host map.baidu.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://map.baidu.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}server {listen 9002;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host loc.map.baidu.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://loc.map.baidu.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
} server {listen 9003;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host api0.map.bdimg.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://api0.map.bdimg.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}
}server {listen 8065;server_name localhost;location /api.map.baidu.com/ {proxy_pass http://api.map.baidu.com/;} location /sapi.map.baidu.com/ {proxy_pass http://sapi.map.baidu.com/;}location /map.baidu.com/ {proxy_pass http://map.baidu.com/;}location /its.map.baidu.com/ {proxy_pass http://its.map.baidu.com/;}location /lbsyun.baidu.com/ {proxy_pass http://lbsyun.baidu.com/;}location /loc.map.baidu.com/ {proxy_pass http://loc.map.baidu.com/;}location /webmap0.map.bdimg.com/ {proxy_pass http://webmap0.map.bdimg.com/;}location /static.tieba.baidu.com/ {proxy_pass http://static.tieba.baidu.com/;}location /or.map.bdimg.com/ {proxy_pass http://or.map.bdimg.com/;}location /ss0.bdstatic.com/ {proxy_pass http://ss0.bdstatic.com/;}location /ss0.baidu.com/ {proxy_pass http://ss0.baidu.com/;}location /d0.map.baidu.com/ {proxy_pass http://d0.map.baidu.com/; }location /d1.map.baidu.com/ {proxy_pass http://d1.map.baidu.com/; } location /d2.map.baidu.com/ {proxy_pass http://d2.map.baidu.com/; }location /d3.map.baidu.com/ {proxy_pass http://d3.map.baidu.com/; }location /online0.map.bdimg.com/ {proxy_pass http://online0.map.bdimg.com/;}location /online1.map.bdimg.com/ {proxy_pass http://online1.map.bdimg.com/;}location /online2.map.bdimg.com/ {proxy_pass http://online2.map.bdimg.com/;}location /online3.map.bdimg.com/ {proxy_pass http://online3.map.bdimg.com/;}location /online4.map.bdimg.com/ {proxy_pass http://online4.map.bdimg.com/;}location /shangetu0.map.bdimg.com/ {proxy_pass http://shangetu0.map.bdimg.com/;}location /shangetu1.map.bdimg.com/ {proxy_pass http://shangetu1.map.bdimg.com/;}location /shangetu2.map.bdimg.com/ {proxy_pass http://shangetu2.map.bdimg.com/;}location /shangetu3.map.bdimg.com/ {proxy_pass http://shangetu3.map.bdimg.com/;}location /shangetu4.map.bdimg.com/ {proxy_pass http://shangetu4.map.bdimg.com/;}location /maponline0.bdimg.com/ {proxy_pass http://maponline0.bdimg.com/;}location /maponline1.bdimg.com/ {proxy_pass http://maponline1.bdimg.com/;}location /maponline2.bdimg.com/ {proxy_pass http://maponline2.bdimg.com/;}location /maponline3.bdimg.com/ {proxy_pass http://maponline3.bdimg.com/;}location /gss0.bdstatic.com/ {proxy_pass http://gss0.bdstatic.com/;}location /gsp0.baidu.com/ {proxy_pass http://gsp0.baidu.com/;}location /g0.api.map.baidu.com/ {proxy_pass http://g0.api.map.baidu.com/;}location /g1.api.map.baidu.com/ {proxy_pass http://g1.api.map.baidu.com/;}location /g2.api.map.baidu.com/ {proxy_pass http://g2.api.map.baidu.com/;}location /g3.api.map.baidu.com/ {proxy_pass http://g3.api.map.baidu.com/;}location /pcsv0.map.bdimg.com/ {proxy_pass http://pcsv0.map.bdimg.com/;}location /pcsv1.map.bdimg.com/ {proxy_pass http://pcsv1.map.bdimg.com/;}location /pcsv2.map.bdimg.com/ {proxy_pass http://pcsv2.map.bdimg.com/;}location /api0.map.bdimg.com/ {proxy_pass http://api0.map.bdimg.com/;}location /api1.map.bdimg.com/ {proxy_pass http://api1.map.bdimg.com/;}location /api2.map.bdimg.com/ {proxy_pass http://api2.map.bdimg.com/;}}server {listen 8066;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host api.map.baidu.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://api.map.baidu.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}server {listen 8067;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_set_header Host mapv.baidu.com;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://mapv.baidu.com;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}
}stream{server {listen 8065;proxy_pass smtp.163.com:465;}
}
7.在mapApi.js中一个一个替换
nginx转发百度地图内网化相关推荐
- 通过 SSH 端口转发实现异地内网服务器互通
异地内网服务器互通,直接通过路由器映射也可以做到,但是由于公网IP并不是固定的,因此这里介绍通过 SSH 端口转发,实现的固定IP访问 场景:内网机器 A.无固定IP机器B.固定IP机器C,其中 B ...
- 信创环境下Nginx正向代理实现内网发送邮件
背景 标题党了,其实不管是不是在信创环境,只要存在网络分区/隔离,我们都可能面临发送邮件的问题: 业务服务要发送邮件但是部署在无法连接互联网的环境A中: Nginx一方面作为静态资源服务,另一方面作为 ...
- 监控视频转发方案探讨-内网转外网
本文介绍如何使用云视睿博的监控转发系统将局域网内的监控摄像头视频转发到互联网上,通过云视睿博流媒体服务器NTV Media Server G3进行流媒体播出.用户通过智能手机.PC等终端远程监看,并可 ...
- nginx转发ArcServer地图服务器出现的http://localhost:6080/arcgis/rest/info?f=json跨域问题
QQ交流群:607330463 GIS开发技术最强交流群 未经允许 禁止转载 可以参考 Access to XMLHttpRequest at 'http://localhost:6080/ar ...
- 使用nginx代理请求到内网
很多公司为了提高云服务器的安全性,采用nginx代理. 原料:三台云服务器,一台带有一个公网ip(),另外两台不需要公网ip,有内网ip即可,只要这三台的内网ip在同一个网段中. 准备:不带公网ip的 ...
- 案例3:百度地图api-个性化地图茶田样式
项目说明 1. 引入百度地图api的js 2. 编写地图容器 3. style样式 4. 创建地图实例 var map = new BMapGL.Map('container'); // 创建Map实 ...
- Linux:Nginx 正向代理实现内网访问互联网
前言: 因为公司的某些系统需要访问互联网上的某些功能,每个系统的服务器都开通访问互联网的能力太麻烦并且不方便管理,所以打算只对一台服务器开通访问互联网的能力,并在此服务器基础上搭建 nginx 正向代 ...
- 内网穿透:SSH远程端口直接转发 或 SSH+Nginx间接转发
说明 木有公网ip,利用云服务器中转,实现外网对本地无公网ip主机web server的访问 SSH远程端口直接转发 windows本地用Python+Flask搭建了一个测试网站 服务器ssh配置信 ...
- Centos使用lanproxy,搭建一个属于自己的内网穿透服务器(附转发失败解决方法),小白向
目录 前言 准备工作 搭建与使用 1. 安装git工具 2. 安装java环境 3. 安装maven工具 4. 搭建Lanproxy 5. 启动内网穿透服务 6. 设置开机自启 转发失败解决方法 前言 ...
- 百度地图——判断用户是否在配送范围内解决方案
需求: 在pc端设置商家的配送范围,用户在下单时,根据用户设置的配送地点判断是否在可配送范围内,并给用户相应的提示. 实现: 1.用百度地图在PC端设置配送范围,可拖拽选择 2.根据用户设置的配送地址 ...
最新文章
- 原生js实现触摸滚动轮播图
- python入门--函数
- SecureCRT内让npm进程后台执行不受关闭终端影响
- gridview实现分页
- 【数码管/定时器/中断】一个定时器控制数码管显示
- 2019西电网安实验班选拔考试
- 数字图像处理(四)——图像编码技术(二)
- Android 12 将支持游戏“边下边玩”
- 95-910-150-源码-FlinkSQL-Flink SQL 的元数据管理
- 为提升 DCP 传输效率,阿里工程师竟然这样做!
- CoreData手动创建托管对象子类时报错
- Spring pom配置详解(转)
- hb100 微波雷达arduino_Arduino Microwave sensor微波传感器模块
- bootice添加黑苹果引导_联想小新13Pro黑苹果系统bigsur教程(OC引导)
- HTTP协议:工作原理
- 华人泰斗黄煦涛逝世,贤伉俪深情六十载
- 女人是这样哄的,学以致用
- 爬取了知乎2.2亿阅读量 有漂亮女朋友是什么体验,结果发现...
- Quartus II LPM使用指南-FIFO篇
- MVC |分部视图 PartialView()
热门文章
- HAL库与标准库的理解
- 初入神经网络剪枝量化5(大白话)
- ArcGis空间分析学习:超市选址分析
- 2022年~全网最真实的软件测试面试题合集
- Representation Learning with Contrastive Predictive Coding 论文阅读笔记
- ECMAScript和JavaScript的关系
- 高压柜无线测温装置-无线无源温度传感器-安科瑞 顾月
- OpenGL ES2.0 的三种变量类型(uniform,attribute和varying)
- BZOJ 5442: [Ceoi2018]Global warming
- 数据库系统(DBS)组成