# 複数のホスト名

## 複数のホスト名/SSLターミネーション設定 <a href="#multiple-hostnames-configurations-for-ssl-termination" id="multiple-hostnames-configurations-for-ssl-termination"></a>

`keeper/guacamole-ssl-nginx`イメージは、Keeper for KCMが提供するGuacamoleイメージのSSLを終端することを特に目的としたものです。これまで、このイメージは単一のホスト名と設定のみに対応していました。

```
    ssl:
        image: keeper/guacamole-ssl-nginx:2
        restart: unless-stopped
        ports:
            - "80:80"
            - "443:443"
        environment:
            SELF_SIGNED:"Y"
            ACCEPT_EULA:"Y"
            CONTENT_TYPE_OPTIONS:"Y"
            CONTENT_SECURITY_POLICY:"Y"
            GUACAMOLE_HOSTNAME: "guacamole"
            SSL_HOSTNAME: "example.net"
```

KCM 2.12.0以降、`keeper/guacamole-ssl-nginx`イメージは、YAML (またはJSON) を受け入れる特殊な`SERVERS`環境変数を使用して、複数のホスト名と設定に対応できます。

`SERVERS`変数では、オブジェクトのYAML (またはJSON) 配列を使用する必要があります。各オブジェクトには、その追加設定に適用する必要のある環境変数の名前と値のペアが含まれています。**未指定の変数はすべて、上位レベル環境から継承されます**。以下に例を示します。

```
    ssl:
        image: keeper/guacamole-ssl-nginx:2
        restart: unless-stopped
        ports:
            - "80:80"
            - "443:443"
        environment:
            SELF_SIGNED:"Y"
            ACCEPT_EULA:"Y"
            CONTENT_TYPE_OPTIONS:"Y"
            CONTENT_SECURITY_POLICY:"Y"
            GUACAMOLE_HOSTNAME: "guacamole"
            
            SERVERS: |
               - SSL_HOSTNAME: "example.net"
               - SSL_HOSTNAME: "*.example.net"
```

上記の設定では、`example.net`と`*.example.net`の両方のホスト名を同等に扱うNGINXインスタンスが生成されます。`SELF_SIGNED`が`Y`に設定されているため、どちらも独自の自己署名証明書を利用します。

より複雑な例:

```
    ssl:
        image: keeper/guacamole-ssl-nginx:2
        restart: unless-stopped
        ports:
            - "80:80"
            - "443:443"
        environment:
            ACCEPT_EULA:"Y"
            CONTENT_TYPE_OPTIONS:"Y"
            CONTENT_SECURITY_POLICY:"Y"
            GUACAMOLE_HOSTNAME: "guacamole"
            
            SERVERS: |
               - SSL_HOSTNAME: "example.net"
                 LETSENCRYPT_ACCEPT_TOS:"Y"
                 LETSENCRYPT_EMAIL=your.email@example.net

               - SSL_HOSTNAME: "*.example.net"
                 SELF_SIGNED:"Y"
```

上記の設定で生成されるNGINXインスタンスでは、`*.example.net`には、自己署名証明書を生成して使用しますが、`example.net`には、Let’s Encryptから証明書を取得します。

**重要:**`SERVERS`の値は文字列であることが\_必要\_なため、上記の例では`|`記号を使用しています。すべてのDocker環境変数は文字列であることが必要なため、この記号を省略すると、後続のYAMLはオブジェクトとして解析され、`docker-compose.yml`の検証は失敗します。

**注意:** NGINXは、設定されたホスト名と一致しない要求があれば、最初のサーバーをデフォルトとして使用します。`SERVERS`で宣言されたサーバーにこの動作をさせる必要がある場合は、そのサーバーを最初に記載する必要があります。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/keeper-connection-manager/jp/authentication/multiple-hostnames.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
