Nginx 转发代理天地图服务
点个关注不迷路,需要其他的也可以留言加我:技术链
公众 好:技术链
就两步:
upstream tianditu_server {
server t0.tianditu.gov.cn weight=1 max_fails=2 fail_timeout=30s;
server t1.tianditu.gov.cn weight=1 max_fails=2 fail_timeout=30s;
server t2.tianditu.gov.cn weight=1 max_fails=2 fail_timeout=30s;
server t3.tianditu.gov.cn weight=1 max_fails=2 fail_timeout=30s;
server t4.tianditu.gov.cn weight=1 max_fails=2 fail_timeout=30s;
server t5.tianditu.gov.cn weight=1 max_fails=2 fail_timeout=30s;
server t6.tianditu.gov.cn weight=1 max_fails=2 fail_timeout=30s;
}
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
location / {
set $agent 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.67';
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
proxy_read_timeout 90;
proxy_send_timeout 90;
proxy_pass http://tianditu_server/;
proxy_set_header User-Agent $agent;
proxy_set_header Content-Length "";
proxy_set_header X-Original-Content-Length $upstream_http_content_length;
proxy_set_header DNT 1;
proxy_set_header Host 't4.tianditu.gov.cn';
if ($arg_tk = '') {
set $args $args&tk=key;
}
set $arg_tk 'key';
}
}
如果有问题按照标题获取完整配置代码