> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8a08bda2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTP(S) 字典源

> 将 HTTP 或 HTTPS 端点配置为 ClickHouse 中的字典源。

如何与 HTTP(S) 服务器交互，取决于[字典在内存中的存储方式](/zh/reference/statements/create/dictionary/layouts/overview)。如果字典使用 `cache` 和 `complex_key_cache` 存储，ClickHouse 会通过 `POST` 方法发送请求来获取所需的键。

设置示例：

<Tabs>
  <Tab title="DDL">
    ```sql theme={null}
    SOURCE(HTTP(
        url 'http://[::1]/os.tsv'
        format 'TabSeparated'
        credentials(user 'user' password 'password')
        headers(header(name 'API-KEY' value 'key'))
    ))
    ```
  </Tab>

  <Tab title="配置文件">
    ```xml theme={null}
    <source>
        <http>
            <url>http://[::1]/os.tsv</url>
            <format>TabSeparated</format>
            <credentials>
                <user>user</user>
                <password>password</password>
            </credentials>
            <headers>
                <header>
                    <name>API-KEY</name>
                    <value>key</value>
                </header>
            </headers>
        </http>
    </source>
    ```
  </Tab>
</Tabs>

<br />

要让 ClickHouse 能够访问 HTTPS 资源，必须在服务器配置中[配置 OpenSSL](/zh/reference/settings/server-settings/settings#openssl)。

设置字段：

| 设置            | 说明                                                 |
| ------------- | -------------------------------------------------- |
| `url`         | 源 URL。                                             |
| `format`      | 文件格式。支持 [Formats](/zh/reference/formats) 中描述的所有格式。 |
| `credentials` | 基本 HTTP 身份验证。可选。                                   |
| `user`        | 身份验证所需的用户名。                                        |
| `password`    | 身份验证所需的密码。                                         |
| `headers`     | HTTP 请求中使用的所有自定义 HTTP 请求头条目。可选。                    |
| `header`      | 单个 HTTP 请求头条目。                                     |
| `name`        | 请求中发送的请求头名称。                                       |
| `value`       | 为特定名称设置的值。                                         |

使用 DDL 命令 (`CREATE DICTIONARY ...`) 创建字典时，会根据配置中 `remote_url_allow_hosts` 部分的内容检查 HTTP 字典的远程主机，以防止数据库用户访问任意 HTTP 服务器。
