> Source: https://docs.cyberelements.io/bastion/4.6/Installation/Docker/HTML5Gateway/

# Installing the HTML5 Gateway Docker

## Importing the Docker image

Before you can create an HTML5 Gateway Docker container, you need to import the Docker image. To do this, launch a shell from which the Docker commands are available to you, as well as the `cleanroom-html5-4.6.1-33-v2.tgz` file. From the shell, run the following command, adjusting the path to the `TGZ` file if it is not in the current directory:

```
1
```

Then check that the import was successful with the following command:

```
1
```

The expected output is as follows. If this is not the case, then the import has failed:

```
1
2
3
4
5
6
```

> **Complete output**
>
> ```
>  1
>  2
>  3
>  4
>  5
>  6
>  7
>  8
>  9
> 10
> 11
> 12
> 13
> 14
> 15
> 16
> 17
> 18
> 19
> 20
> 21
> 22
> 23
> 24
> 25
> 26
> 27
> 28
> 29
> 30
> 31
> 32
> 33
> 34
> 35
> 36
> 37
> 38
> 39
> 40
> 41
> 42
> 43
> 44
> 45
> 46
> 47
> 48
> 49
> 50
> 51
> 52
> 53
> 54
> 55
> 56
> 57
> 58
> 59
> 60
> 61
> 62
> 63
> 64
> 65
> 66
> 67
> 68
> 69
> 70
> 71
> 72
> 73
> ```

## Container configuration

### Environment variables

#### Variables for deployment by pairing

| Name | Mandatory | Default value | Comment |
|---|---|---|---|
| `ENV_MEDIATION` | YES |  | Used for pairing connection. Indicates the DNS name or IP address for connecting to the web interface of a CyberElements Bastion platform. |
| `ENV_TOKEN` | YES |  | Used for pairing connection. Indication of the pairing token to be used for connection to the Mediation Controller. |
| `ENV_NO_CHECK_CERT` | NO | `false` | Used for pairing connections. Whether or not to disable Mediation Controller web certificate checking, useful with CyberElements Bastion when accessing via IP address or when the web certificate is not a certificate recognized by the default public certification authorities. Accepted values: `true` or `false`. |

#### Variables for manual deployment

| Name | Mandatory | Default value | Comment |
|---|---|---|---|
| `ENV_GW_CERT_NAME` | YES |  | Used for connection with manual configuration. Name of the certificate file for connecting to the SSL Router. |
| `ENV_GW_CERT_PASSWORD` | YES |  | Used for connection with manual configuration. Certificate file password for connection to the SSL Router. |
| `ENV_SSL_ROUTER_IP` | YES |  | Used for connection with manual configuration. IP address or DNS name of the SSL router to which the HTML5 Gateway will connect. |
| `ENV_SSL_ROUTER_PORT` | NO | `443` | Used for connection with manual configuration. Port of the SSL router to which the HTML5 Gateway will connect. |

#### Various variables

| Name | Mandatory | Default value | Comment |
|---|---|---|---|
| `ENV_DISABLE_RSYSLOG` | NO | `false` | Service deactivation `rsyslog`. Accepted values: `true` or `false`. |

### Volumes

| Volume | Comment |
|---|---|
| `/etc/ipdiva/` | HTML5 Gateway configuration volume. We recommend mounting it on a named volume or on the host machine's file system. |
| `/opt/certificates/` | Volume containing the HTML5 Gateway certificate(s) when configuring without pairing. |
| `/var/log/` | Volume containing the HTML5 Gateway logs. |

### Ports

| Port | Comment |
|---|---|
| `8080` | HTML5 service listening port. |

## Deployment of the HTML5 Gateway Docker

### Deployment with pairing

> **Prerequisites**
>
> Before deploying the HTML5 Gateway Docker, you must [obtain a pairing token](https://docs.cyberelements.io/bastion/4.6/Usage/Configuration/AdminConsole/CreatePairingTokenForEdgeGateway/#__tabbed_1_2).

The deployment described below will use all available volumes (except `/opt/certificates/` that is not useful in this context) and expose all ports.
The volumes will be mounted on the host machine's file system with the location `HTML5_GATEWAY_REP`. Inside this location are the following subdirectories:

- config
- log

You can customize the variables for the following commands:

| Custom value | Variable | Comment |
|---|---|---|
|  | `DOCKER_NAME` | Name of the Docker container. |
|  | `HTML5_GATEWAY_REP` | Location on the file system to mount the volumes. |
|  | `ENV_MEDIATION_VALUE` | Value of the `ENV_MEDIATION` [environment variable](#environment-variables). |
|  | `ENV_TOKEN_VALUE` | Value of the `ENV_TOKEN` [environment variable](#environment-variables). |
|  | `ENV_NO_CHECK_CERT_VALUE` | Value of the `ENV_NO_CHECK_CERT` [environment variable](#environment-variables). |

Create the directory tree required for mounting volumes on the file system:

**Bash**

> ```
> 1
> 2
> ```

**PowerShell**

> ```
> 1
> ```

And finally, start a new container:

**Bash**

> ```
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> ```

**PowerShell**

> ```
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> ```

The container logs can be viewed using the following command:

```
1
```

### Manual deployment

> **Prerequisites**
>
> Before deploying the HTML5 Gateway Docker, you must have the certificate required for the HTML5 Gateway.

> **Passwords visible with `docker inspect`**
>
> The environment variables of a container, certificate passwords included, remain readable by anyone allowed to run `docker inspect` on the Docker server. The [deployment with pairing](#deployment-with-pairing), which uses no certificate password, should therefore be preferred.

The deployment described below will use all available volumes and expose all ports.
The volumes will be mounted on the host machine's file system with the location `MANUAL_REP`. Inside this location are the following subdirectories:

- config
- log
- certificates

You can customize the variables for the following commands:

| Custom value | Variable | Comment |
|---|---|---|
|  | `MANUAL_NAME` | Name of the Docker container. |
|  | `MANUAL_REP` | Location on the file system to mount the volumes. |
|  | `ENV_GW_CERT_NAME_VALUE` | Value of the `ENV_GW_CERT_NAME` [environment variable](#environment-variables). |
|  | `ENV_SSL_ROUTER_IP_VALUE` | Value of the `ENV_SSL_ROUTER_IP` [environment variable](#environment-variables). |
|  | `ENV_SSL_ROUTER_PORT_VALUE` | Value of the `ENV_SSL_ROUTER_PORT` [environment variable](#environment-variables). |

Create the directory tree required for mounting volumes on the file system:

**Bash**

> ```
> 1
> 2
> 3
> ```

**PowerShell**

> ```
> 1
> ```

Then place the certificates for the HTML5 Gateway and the recording service in `MANUAL_REP/certificates`.

So that the certificate passwords are not kept in the shell history, enter them in environment variables of the current session (the input is not displayed):

**Bash**

> ```
> 1
> 2
> ```

**PowerShell**

> ```
> 1
> ```

Finally, start a new container:

**Bash**

> ```
>  1
>  2
>  3
>  4
>  5
>  6
>  7
>  8
>  9
> 10
> ```

**PowerShell**

> ```
>  1
>  2
>  3
>  4
>  5
>  6
>  7
>  8
>  9
> 10
> ```

Once the container has started, remove these variables from the session:

**Bash**

> ```
> 1
> ```

**PowerShell**

> ```
> 1
> ```

The container logs can be viewed using the following command:

```
1
```

## Configuration of the Mediation Controller

In order for the new HTML5 Gateway Docker to be operational, the Mediation Controller Server still needs to be configured via SSH or console access and `root` permissions.

This last setting is required to allow the Mediation Controller to communicate with the HTML5 service.
However, this configuration varies depending on the location of the HTML5 Gateway Docker:

**Placed in the DMZ**

> The overall diagram is as follows:
>
> ```mermaid
> flowchart LR
>     subgraph DMZ
>         direction TB
>         HTML5(HTML5 Gateway Docker)
>         MED(Mediation Controller)
>     end
>
>     subgraph LAN
>         GW(Edge Gateway)
>     end
>
>
>     MED -.-> |Connection to HTML5 service ; TCP 8080| HTML5
>     HTML5 --> |TLS Tunnel| MED
>     MED ~~~ GW
>     GW --> |TLS Tunnel| MED
>     GW ~~~ MED
>
>     linkStyle 0 stroke:#d22,color;
> ```
>
> In this context, it will be necessary to add the information given below to the `/etc/ipdiva/httpd/commonParameters.extra.conf` file or to create it.
> Customization of the settings is available:
>
> | Custom value | Variable | Comment |
> |---|---|---|
> |  | `HTML5_URL_DMZ` | URL configured when declaring the HTML5 Gateway in the administration console. |
> |  | `HTML5_IP_DMZ` | DNS name or IP address of the Docker server on which the HTML5 Gateway Docker is active. |
> |  | `HTML5_PORT_DMZ` | Port published by the Docker server for the HTML5 Gateway Docker. |
>
> ```
>  1
>  2
>  3
>  4
>  5
>  6
>  7
>  8
>  9
> 10
> 11
> 12
> 13
> ```

**Placed in the LAN accessible by an Edge Gateway**

> The overall diagram is as follows:
>
> ```mermaid
> flowchart LR
>     subgraph DMZ
>         direction TB
>         MED(Mediation Controller)
>     end
>
>     subgraph LAN
>         HTML5(HTML5 Gateway Docker)
>         GW(Edge Gateway)
>     end
>
>
>     MED -.- | Connection to HTML5 service ; through TLS Tunnel| GW -.-> |Connection to HTML5 service ; TCP 8080| HTML5
>     HTML5 --> |TLS Tunnel| MED
>     GW --> |TLS Tunnel| MED
>
>     linkStyle 0,1 stroke:#d22,color;
> ```
>
> In this context, it will be necessary to add the information given below to the `/etc/ipdiva/httpd/commonParameters.extra.conf` file or to create it.
> Customization of the settings is available:
>
> | Custom value | Variable | Comment |
> |---|---|---|
> |  | `HTML5_URL_LAN` | URL configured when declaring the HTML5 Gateway in the administration console. |
> |  | `GW_NAME_LAN` | Name of the Edge Gateway used to connect to the HTML5 service. The pipe character at the end of the line **must be kept**. |
> |  | `ORGANIZATION_NAME_LAN` | Name of the organization to which the Edge Gateway connects. |
> |  | `HTML5_IP_LAN` | DNS name or IP address of the Docker server on which the HTML5 Gateway Docker is active. |
> |  | `HTML5_PORT_LAN` | Port published by the Docker server for the HTML5 Gateway Docker. |
>
> ```
>  1
>  2
>  3
>  4
>  5
>  6
>  7
>  8
>  9
> 10
> 11
> 12
> 13
> 14
> 15
> 16
> 17
> 18
> 19
> 20
> 21
> ```
>
> > **Tip**
> >
> > This configuration can also be used in the following situation where a Docker Edge Gateway and a Docker HTML5 Gateway are running in the same Docker network:
> >
> > ```mermaid
> > flowchart LR
> >     subgraph DMZ
> >         direction TB
> >         MED(Mediation Controller)
> >     end
> >
> >     subgraph LAN
> >         subgraph docker[Docker Server]
> >             HTML5([HTML5 Gateway Docker])
> >             GW([Edge Gateway])
> >         end
> >     end
> >
> >
> >     MED -.- | Connection to HTML5 service ; through TLS Tunnel| GW -.-> |Connection to HTML5 service ; TCP 8080 through Docker network| HTML5
> >     HTML5 --> |TLS Tunnel| MED
> >     GW --> |TLS Tunnel| MED
> >
> >     linkStyle 0,1 stroke:#d22,color;
> > ```
> >
> > > **Example**
> > >
> > > In this example, we will deploy an Edge Gateway and an HTML5 Gateway on the same Docker server.
> > >
> > > The infrastructure used for the example is as follows:
> > >
> > > - Mediation Controller server
> > >     - Web IP address: `10.0.10.10`
> > >     - Organization name: `my-organization-name`
> > >     - Token for Edge Gateway: `YJ5N-JN05-N5LS-N26H-7JHA-HZ9R-BGJF-MAVH`
> > >     - Token for HTML5 Gateway: `ATCW-OMVR-0RY4-LW1M-D9G9-H5VF-WPX5-YCXF`
> > >     - URL for accessing the HTML5 service: `HTML5_DOCKER`
> > > - Docker server
> > >     - Docker network name: `cyberelements-cleanroom-network`
> > >     - Edge Gateway
> > >         - Name: `my-edge-gateway-docker`
> > >         - Root location on the file system: `/opt/my-edge-gateway-docker`
> > >     - HTML5 Gateway
> > >         - Name: `my-html5-gateway-docker`
> > >         - Root location on the file system: `/opt/my-html5-gateway-docker`
> > >
> > > First, on the Docker server, you need to create the tree structure for mounting the Docker volumes:
> > >
> > > ```
> > > 1
> > > 2
> > > 3
> > > 4
> > > 5
> > > 6
> > > ```
> > >
> > > Then create a `bridge` type Docker network so that the two containers can communicate with each other:
> > >
> > > ```
> > > 1
> > > ```
> > >
> > > Next, start the Edge Gateway container. Note that the example establishes a connection by pairing, with access to the Mediation Controller via its IP address and no certificate check added. In addition, the `--network` parameter is added to specify the use of the previously created Docker network:
> > >
> > > ```
> > >  1
> > >  2
> > >  3
> > >  4
> > >  5
> > >  6
> > >  7
> > >  8
> > >  9
> > > 10
> > > 11
> > > 12
> > > 13
> > > ```
> > >
> > > Next, start the HTML5 Gateway container. Note that the example establishes a connection by pairing, with access to the Mediation Controller via its IP address and no certificate check added. In addition, the `--network` parameter is added to specify the use of the previously created Docker network, and since access to the HTML5 service will go through the Docker network, publishing port 8080 is not necessary:
> > >
> > > ```
> > > 1
> > > 2
> > > 3
> > > 4
> > > 5
> > > 6
> > > 7
> > > 8
> > > ```
> > >
> > > Finally, the `/etc/ipdiva/httpd/commonParameters.extra.conf` file on the Mediation Controller server(s) needs to be configured. The following section should be added:
> > >
> > > ```
> > >  1
> > >  2
> > >  3
> > >  4
> > >  5
> > >  6
> > >  7
> > >  8
> > >  9
> > > 10
> > > 11
> > > 12
> > > 13
> > > 14
> > > 15
> > > 16
> > > 17
> > > 18
> > > 19
> > > 20
> > > 21
> > > ```

Before applying the new settings, you must check that the new configuration does not cause any blocking errors for the Apache2 web server.
To do this, run the following command:

```
1
```

If the return is `Syntax OK` then the changes can be applied with the command below. Otherwise, check the configuration of your `/etc/ipdiva/httpd/commonParameters.extra.conf` file.

```
1
```
