GeoDNS

    內容表格
    1. 1. 說明
    2. 2. 開始佈署
    3. 3. 設定 DNS

    版本為 14:33, 30 Nov 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    說明

    如果要做到類似 Cloudflare 分散式的 CDN 分流服務,除了需要 Reverse Proxy 服務以外,還要再搭配 GeoDNS 服務,這樣用戶在存取網站時,就能依照自己所屬的國家,使用連線最近的 Reverse Proxy,進而達到網站分流與加速網站存取速度。

    本篇運用 Docker 技術就能在幾分鐘內完成佈署 GeoDNS 所有需要的元件,這樣就可以將時間用在設定網域上。

    開始佈署

    新增 docker-compose.yml

    version: '2'
    
    services:
      geodns:
        restart: always
        image: sameersbn/bind:9.10.3-20180127
        container_name: geodns
        ports:
         - "53:53/udp"
         - "53:53/tcp"
        environment:
         - ROOT_PASSWORD=yourpassword
         - WEBMIN_ENABLED=false
        volumes:
         - /docker_vol/geodns/data:/data
    

    新增設定檔需要的目錄

    mkdir  /docker_vol/geodns/data
    

    新增並啟動服務 geodns

    docker-compose up -d
    

    完成

    設定 DNS

    編輯 /docker_vol/geodns/data/bind/etc/named.conf

    ...
     include "/etc/bind/named.conf.options";
    include "/etc/bind/named.conf.local";
    //include "/etc/bind/named.conf.default-zones";
    ...
    

    註解第三行,並加上以下幾行

    // GeoDNS Configuration
    // The download link to the GeoIP.acl
    // http://geoip.site/download/MaxMind/GeoIP.acl.gz
    //
    // acl file sepified the IP zones of countries.
    include "/etc/bind/GeoIP.acl";  
    
    // view settings for all countries
    view "USA" {
      // The contents of this view will be presented to users
      // from the USA.
      match-clients { US; };
      zone "example.com" {
        // This is my zonefile with the US view.
        file "/etc/bind/zones/usa/example.com.db";
        type master;
      };
    };
    
    view "Taiwan" {
      // The contents of this view will be presented to users
      // from the Taiwan.  
      match-clients { TW; };
      zone "example.com" {
        file "/etc/bind/zones/taiwan/example.com.db";
        type master;
      };
    };
    
    view "Global" {
      // The contents of this view will be presented to users
      // outside the USA and Taiwan.
      zone "example.com" {
        // This is my zonefile with the default view.
        file "/etc/bind/zones/global/example.com.db";
        type master;
      };
    }
    
    Powered by MindTouch Core