IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> nginx转发百度地图内网化 -> 正文阅读

[系统运维]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中一个一个替换

  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2022-03-30 19:10:50  更:2022-03-30 19:11:54 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/15 23:56:49-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码