Pages domains API

Pages domains API

GitLab Pages 中连接自定义域和 TLS 证书的端点.

必须启用 GitLab 页面功能才能使用这些端点. 了解有关和使用功能的更多信息.

  1. [ { "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" } } ]

List pages domains

Get a list of project pages domains. The user must have permissions to view pages domains.

  1. GET /projects/:id/pages/domains
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/pages/domains"
  1. [ { "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" } } ]

获取单个项目页面域. 用户必须具有查看页面域的权限.

  1. GET /projects/:id/pages/domains/:domain
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/pages/domains/www.domain.example"
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"

    Create new pages domain

    1. 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"
    1. 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"
    1. 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"
    1. { "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" } }

    更新现有的项目页面域. 用户必须具有更改现有页面域的权限.

    1. 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"
    1. 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"
    1. { "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" } }
    1. 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"
    1. { "domain": "ssl.domain.example", "url": "https://ssl.domain.example", "auto_ssl_enabled": true }

    要删除附加到 Pages 域的 SSL 证书,请运行:

    1. 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"
    1. { "domain": "ssl.domain.example", "url": "https://ssl.domain.example", "auto_ssl_enabled": false }

    Delete pages domain