ドメインAPI

GitLabPagesのカスタムドメインとTLS証明書を接続するためのエンドポイント。

これらのエンドポイントを使用するには、GitLab Pages 機能を有効にする必要があります。機能の管理と使用の詳細については、こちらをご覧ください。

全ページドメイン一覧

すべてのページのドメインのリストを取得します。 ユーザーには管理者権限が必要です。

GET /pages/domains
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/pages/domains"
[
  {
    "domain": "ssl.domain.example",
    "url": "https://ssl.domain.example",
    "project_id": 1337,
    "auto_ssl_enabled": false,
    "certificate": {
      "expired": false,
      "expiration": "2020-04-12T14:32:00.000Z"
    }
  }
]

ドメイン一覧

プロジェクトページのドメインのリストを取得します。 ユーザーにはページドメインを表示する権限が必要です。

GET /projects/:id/pages/domains
属性 タイプ 必須 説明
id 整数/文字列 はい 認証されたユーザーが所有するプロジェクトのIDまたはURLエンコードされたパス
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/pages/domains"
[
  {
    "domain": "www.domain.example",
    "url": "http://www.domain.example"
  },
  {
    "domain": "ssl.domain.example",
    "url": "https://ssl.domain.example",
    "auto_ssl_enabled": false,
    "certificate": {
      "subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",
      "expired": false,
      "certificate": "-----BEGIN CERTIFICATE-----\n\n-----END CERTIFICATE-----",
      "certificate_text": "Certificate:\n\n"
    }
  }
]

単一ページドメイン

単一のプロジェクトPagesドメインを取得します。 ユーザーには、Pagesドメインを表示する権限が必要です。

GET /projects/:id/pages/domains/:domain
属性 タイプ 必須 説明
id 整数/文字列 はい 認証されたユーザーが所有するプロジェクトのIDまたはURLエンコードされたパス
domain はい ユーザーが指定したカスタムドメイン
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/pages/domains/www.domain.example"
{
  "domain": "www.domain.example",
  "url": "http://www.domain.example"
}
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"
{
  "domain": "ssl.domain.example",
  "url": "https://ssl.domain.example",
  "auto_ssl_enabled": false,
  "certificate": {
    "subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",
    "expired": false,
    "certificate": "-----BEGIN CERTIFICATE-----\n\n-----END CERTIFICATE-----",
    "certificate_text": "Certificate:\n\n"
  }
}

新規ページのドメイン作成

新しいページドメインを作成します。 ユーザーは新しいページドメインを作成する権限を持っている必要があります。

POST /projects/:id/pages/domains
属性 タイプ 必須 説明
id 整数/文字列 はい 認証されたユーザーが所有するプロジェクトのIDまたはURLエンコードされたパス
domain はい ユーザーが指定したカスタムドメイン
auto_ssl_enabled ブーリアン いいえ カスタムドメイン用にLet’s Encryptが発行するSSL証明書の自動生成を可能にします。
certificate ファイル/文字列 いいえ PEM形式の証明書で、中間体は最も特異的なものから最も特異的でないものの順に続きます。
key ファイル/文字列 いいえ PEM 形式の証明書キー。
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "domain=ssl.domain.example" --form "certificate=@/path/to/cert.pem" --form "key=@/path/to/key.pem" "https://gitlab.example.com/api/v4/projects/5/pages/domains"
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "domain=ssl.domain.example" --form "certificate=$CERT_PEM" --form "key=$KEY_PEM" "https://gitlab.example.com/api/v4/projects/5/pages/domains"
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "domain=ssl.domain.example" --form "auto_ssl_enabled=true" "https://gitlab.example.com/api/v4/projects/5/pages/domains"
{
  "domain": "ssl.domain.example",
  "url": "https://ssl.domain.example",
  "auto_ssl_enabled": true,
  "certificate": {
    "subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",
    "expired": false,
    "certificate": "-----BEGIN CERTIFICATE-----\n\n-----END CERTIFICATE-----",
    "certificate_text": "Certificate:\n\n"
  }
}

ページのドメインを更新

既存のプロジェクトページドメインを更新します。 ユーザーは既存のページドメインを変更する権限を持っている必要があります。

PUT /projects/:id/pages/domains/:domain
属性 タイプ 必須 説明
id 整数/文字列 はい 認証されたユーザーが所有するプロジェクトのIDまたはURLエンコードされたパス
domain はい ユーザーが指定したカスタムドメイン
auto_ssl_enabled ブーリアン いいえ カスタムドメイン用にLet’s Encryptが発行するSSL証明書の自動生成を可能にします。
certificate ファイル/文字列 いいえ PEM形式の証明書で、中間体は最も特異的なものから最も特異的でないものの順に続きます。
key ファイル/文字列 いいえ PEM 形式の証明書キー。

証明書の追加

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --form "certificate=@/path/to/cert.pem" --form "key=@/path/to/key.pem" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --form "certificate=$CERT_PEM" --form "key=$KEY_PEM" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"
{
  "domain": "ssl.domain.example",
  "url": "https://ssl.domain.example",
  "auto_ssl_enabled": false,
  "certificate": {
    "subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",
    "expired": false,
    "certificate": "-----BEGIN CERTIFICATE-----\n\n-----END CERTIFICATE-----",
    "certificate_text": "Certificate:\n\n"
  }
}

PagesカスタムドメインのLet’s Encryptインテグレーションを有効にします。

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --form "auto_ssl_enabled=true" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"
{
  "domain": "ssl.domain.example",
  "url": "https://ssl.domain.example",
  "auto_ssl_enabled": true
}

証明書の削除

Pagesドメインに接続されているSSL証明書を削除するには、以下を実行します:

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --form "certificate=" --form "key=" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"
{
  "domain": "ssl.domain.example",
  "url": "https://ssl.domain.example",
  "auto_ssl_enabled": false
}

ドメイン削除

既存のプロジェクトページのドメインを削除します。

DELETE /projects/:id/pages/domains/:domain
属性 タイプ 必須 説明
id 整数/文字列 はい 認証されたユーザーが所有するプロジェクトのIDまたはURLエンコードされたパス
domain はい ユーザーが指定したカスタムドメイン
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"