> Source: https://docs.cyberelements.io/saas/no/Usage/Reference/ConfigurationFiles/EdgeGateway/GatewayXml/

# gateway.xml

`gateway.xml` is the configuration of an Edge Gateway: the Mediation Controller it connects to, the certificate it presents, its TLS settings and its web access options. It is the first file to look at when an Edge Gateway does not come up.

| Property | Value |
|---|---|
| **Component** | Edge Gateway |
| **Path** | `/etc/ipdiva/gateway/gateway.xml` |
| **Owner and permissions** | `ipdivagateway:ipdivagateway`, `400` |
| **Package** | none, written at installation |
| **Format** | XML |

> **One directory per instance**
>
> Each additional instance of the Edge Gateway has its own directory, `/etc/ipdiva/gateway-<instance>/`, named after the instance, with its own `gateway.xml`. What this page describes applies to each of them; such an instance is restarted by `systemctl restart ipdiva-gateway@-<instance>.service`.

## Structure

A single `<gateway>` element. The two values set at installation are `<server>` and the certificate of `<ssl>`:

| Section | Holds |
|---|---|
| [`<gateway>`](#gateway-root) | The address of the SSL Router of the Mediation Controller, the local control interface of the Edge Gateway, its services file, the compression and the throughput of its tunnels. |
| [`<timeout>`](#timeout) | The wait between two connection attempts to the Mediation Controller. |
| [`<pipe>`](#pipe) | The connection of the Edge Gateway to the Mediation Controller: keep-alive, queues, congestion. |
| [`<proxy>`](#proxy) | The outgoing proxy through which the Edge Gateway reaches the Mediation Controller. |
| [`<ssl>`](#ssl) | The TLS of the connection to the Mediation Controller: certificate and its password, certification authorities, versions and cipher suites. |
| [`<session>`](#session) | The TLS profiles applied to the encrypted connections towards the target servers. |
| [`<webaccess>`](#webaccess) | The processing of the web accesses: authentication, proxies, rewriting of the pages, cookies. |
| [`<vlan>`](#vlan) | The network interface through which the Edge Gateway reaches the target servers. |
| [`<socket>`](#socket) | The options of the sockets. |
| [`<license>`](#license) | A former licence mechanism, absent from the installed file. |
| [`<debugger>`](#debugger) | The debugging console. |

The installed file also holds `<ticket>`: the Edge Gateway reads it without using it. Finally, it holds `<openvpn>`, reserved for a former VPN access that CyberElements no longer uses: the section is not described here, and the VPN of the console does not read it.

> **The file holds the password of the certificate**
>
> `<ssl><password>` is in clear text, which is why the file can only be read by its owner. Keep these permissions: the security guide checks them: see [Edge Gateway certificate and private key](https://docs.cyberelements.io/saas/no/Security/GatewayCertificates/).

## Parameters

The tables list every element and every attribute that the Edge Gateway reads. Two columns give a value:

- **Default value**: the value written in the file as installed. A dash marks an element absent from the installed file; *set at installation* marks a value that the installation writes from what it has collected.
- **If the element is absent**: the value that the Edge Gateway uses when it does not find the element.

An element is written as a path from its section, and `@` marks an attribute:

- `credentials/login` is the `<login>` element of the `<credentials>` element of `<proxy>`;
- `hosts/host/@target` is the `target` attribute of a `<host>` element of `<hosts>`, in `<session>`;
- `sslconf/*` designates all the elements that `<sslconf>` accepts: they are those of `<ssl>`.

### `<gateway>`

Elements placed directly under `<gateway>`. The Edge Gateway reads the file once, at startup. A value that is not a number or a boolean in `rate`, `rate-detection`, `useoldprotocol`, `ntlmv2` or `ntlm-sspi` prevents its start.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `server` | set at installation | no connection | Address of the SSL Router of the Mediation Controller, as `<address>:<port>:ssl`; without `:ssl`, the connection is not encrypted. Several addresses separated by `;` are tried in turn, the next one after 3 failures. The part before the first `:` is also the name expected in the certificate of the Mediation Controller when `ssl/cert-peernames` is empty. Ignored when a licence gives the server. Empty: the Edge Gateway starts but does not connect. |
| `network-id` | empty | empty | Numeric identifier, from 0 to 65535, that the Edge Gateway requests in its routing domain and announces to the Mediation Controller when it connects. |
| `services` | set at installation | `services.xml` next to `gateway.xml` | Path of the file of services that the Edge Gateway loads at startup, and in which it saves the services added or removed through its local interface. |
| `nodes-certs` | — | `ssl/certs/` next to `gateway.xml` | Directory of the certificates of the other nodes, which the Edge Gateway loads at startup and saves when it stops. |
| `rpc-listen` | set at installation | `127.0.0.1:9080` | Local address and port of the XML-RPC interface through which the other components of the host manage the Edge Gateway: services, certificates, certification authorities, stop. Each instance needs its own port. Empty: no interface. |
| `compression` | `zlib` | `zlib` | Compression of the tunnels, announced to the Mediation Controller: `zlib`, `none` or `lzo` (obsolete). Case does not matter; any other value means `zlib`. |
| `rate` | `0` | `0` | Maximum throughput of the sessions of the Edge Gateway, in thousands of bytes per second. `0`: no limit. A licence that sets a throughput prevails. |
| `rate-detection` | — | `true` | `false`: the throughput measured on the connections is no longer taken into account; it is treated as unlimited. |
| `periodic-licence-check` | `false` | `false` | `true`: the Edge Gateway stops when the licence file (`license/license`, by default `gateway.lic` next to `gateway.xml`) changes or disappears; it checks it every 10 seconds. If the file is missing at startup, the Edge Gateway stops at once, and systemd restarts it in a loop. |
| `useoldprotocol` | `false` | `false` | `true`: the Edge Gateway presents itself to the Mediation Controller with the former protocol, without the fingerprints of its integrity file, and uses the former session identifiers. |
| `ntlmv2` | — | `true` | `false`: the NTLM authentication that the Edge Gateway performs towards the web servers and the HTTP proxies uses NTLMv1 instead of NTLMv2. |

### `<timeout>`

Reconnection to the Mediation Controller. Durations in milliseconds.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `reconnect` | `15000` | `15000` | Wait between two connection attempts to the Mediation Controller, and after the loss of the connection. It is also the maximum wait for the answer of the Mediation Controller once the connection is open. |
| `ping` | — | `60000` | Former setting: when the element is present, its value replaces that of `<pipe>/ping-timeout`. |

### `<pipe>`

The connection of the Edge Gateway to the Mediation Controller. Durations in milliseconds.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `ping-timeout` | `60000` | `60000` | Duration without data received after which the Edge Gateway sends a ping. It also sends one when it has sent nothing for half this duration. |
| `ping-response-timeout` | — | `5000` | Additional duration granted to the Mediation Controller after a ping: if nothing is received within `ping-timeout` plus this duration, the Edge Gateway closes the connection and reconnects. |
| `connect-timeout` | — | `10000` | Maximum duration of the opening of the connection to the Mediation Controller, then again of the TLS negotiation. |
| `fifo-recv-len` | — | `5000` | Capacity, in packets, of the reception queue of the connection. |
| `push-recv-timeout` | — | `30000` | Maximum wait to place a received packet in a full reception queue. Beyond it, the packet is dropped. |
| `pop-recv-timeout` | — | `20000` | Maximum wait for a packet when the Edge Gateway reads the reception queue. Beyond it, the read fails. |
| `sent-limit` | — | `2097152` | Maximum volume, in bytes, waiting in the send queue of the connection. Beyond it, a new packet waits until space is freed. |
| `congestion-ratio` | — | `75` | Percentage of `sent-limit` beyond which the route through the connection is considered congested. |

### `<proxy>`

Outgoing proxy through which the Edge Gateway reaches the Mediation Controller. The pairing writes `type`, `address`, `login`, `password` and `domain`.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `type` | `no` | no proxy | Kind of proxy: `no` or `none`; `http`, `https` or `connect` (HTTP proxy, method CONNECT); `socks4`; `sock5` for SOCKS 5 (written so, `socks5` is not recognised). Case-sensitive; an unrecognised value leaves no proxy. |
| `address` | empty | empty | Address and port of the proxy. Empty: no proxy, whatever `type`. |
| `login` | empty | empty | Account presented to a proxy that requires an authentication (Basic, Digest or NTLM for an HTTP proxy, user name for SOCKS 5). |
| `password` | empty | empty | Password of the proxy account, in clear text. |
| `domain` | empty | empty | Domain of the proxy account, used by the NTLM authentication. |
| `credentials/login` | — | — | Other form of `login`, read after it: when present, it prevails. |
| `credentials/password` | — | — | Other form of `password`, read after it: when present, it prevails. |
| `credentials/domain` | — | — | Other form of `domain`, read after it: when present, it prevails. |
| `credentials/mediation` | — | — | Former name of `credentials/domain`, read after it: when present, it prevails. |

### `<ssl>`

TLS of the connection to the Mediation Controller, where the Edge Gateway is the client: its certificate, the trust it grants to the certificate of the Mediation Controller, cipher suites and protocol versions. The TLS context is built only when `cert` is set. An error on `ca-dir`, `dh-file`, `ecdh-curve`, the cipher lists or the certificate prevents the start of the Edge Gateway. If the file named by `ca-file` does not exist, the Edge Gateway stops configuring TLS at that point: certificate, cipher suites and verification are not loaded.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `cert` | set at installation | no TLS context, no identity | Certificate and private key of the Edge Gateway: PKCS#12 when the file ends in `.p12`, PEM when it ends in `.pem`; any other extension prevents the start. Without a licence, the common name of this certificate is the identity of the Edge Gateway. The pairing replaces it with `ssl/<name>.p12`. |
| `pkcs12` | — | — | Former name of `cert`, read only when `cert` is absent. |
| `key` | — | — | Former name of `cert`, read only when `cert` and `pkcs12` are absent. |
| `password` | `PASSWORD` | built-in passwords tried | Password of the certificate, in clear text. For a PEM file, several values separated by `;` are tried in turn. The Edge Gateway also uses it to protect a certificate renewed through its local interface. The pairing sets a random value. |
| `ca-file` | — | — | File of certification authorities trusted to verify the certificate of the Mediation Controller. |
| `calist` | — | — | Former name of `ca-file`; when present, it takes precedence over it. |
| `ca-dir` | set at installation | — | Directory of certification authorities: every file it contains, subdirectories included, is loaded. The local interface of the Edge Gateway adds and removes authorities in it. A missing directory prevents the start of the Edge Gateway. |
| `allowed-ca-file` | — | — | File of the certification authorities allowed to sign the certificate of the Mediation Controller: a certificate whose issuer is not in it is refused. |
| `cipherlist` | `!ADH:` `!AECDH:` `!MD5:` `kEECDH+AES:` `kEDH+AES:` `AES256+RSA:` `3DES+RSA` | OpenSSL default | Cipher suites up to TLS 1.2, in the OpenSSL syntax. A list refused by OpenSSL prevents the start of the Edge Gateway. |
| `cipherlist-tls1.3` | `TLS_CHACHA20_POLY1305_SHA256:` `TLS_AES_256_GCM_SHA384:` `TLS_AES_128_GCM_SHA256` | OpenSSL default | Cipher suites of TLS 1.3, separated by `:`. A list refused by OpenSSL prevents the start of the Edge Gateway. |
| `min-version` | `tls1.3` | `tls1.1` | Minimum version of the protocol: `tls1`, `tls1.1`, `tls1.2` or `tls1.3`. Any other value is reported in the log and leaves no minimum. With `tls1.3`, the Mediation Controller must accept TLS 1.3. |
| `max-version` | empty | no maximum | Maximum version of the protocol, with the same values as `min-version`. Empty: no maximum. |
| `version` | — | — | Former setting: ignored, with an error in the log, when `min-version` or `max-version` is present. Otherwise it sets the lowest version accepted (`tls1`, `tls1.1`, `tls1.2`, `tls1.3`, also written `tlsv1.2`…). |
| `verify-cert` | `true` | `true` | `true`: the certificate of the Mediation Controller is verified against the trusted authorities, and the connection is refused if it is not valid. `false`: no verification, and `verify-certhostnamematch` has no effect. |
| `verify-certhostnamematch` | `true` | `false` | `true` (with `verify-cert` at `true`): the common name or one of the alternative names of the certificate of the Mediation Controller must be one of the names of `cert-peernames`, or, when it is empty, the address of `<server>` as written (before the first `:`). |
| `cert-peernames` | — | the address of `<server>` | Names accepted in the certificate of the Mediation Controller, used by `verify-certhostnamematch`. |
| `cert-peername` | — | — | Former form of `cert-peernames`, holding a single name; read only when `cert-peernames` is absent or empty. |
| `verify-depth` | — | `0` | Maximum depth of the certificate chain accepted. `0` keeps the OpenSSL default. |
| `accept-expired-cert` | — | `false` | `true`: an expired certificate of the Mediation Controller is accepted, and logged. |
| `secure-renegociation` | — | `force` | `force`: behaviour of OpenSSL; `no`: disables the session tickets; `allowUnsecure`: allows the unsecure legacy renegotiation. Case-sensitive; any other value is reported in the log and ignored. |

### `<session>`

TLS profiles that the Edge Gateway applies to its encrypted connections to the target servers (HTTPS and other TLS services). Without a profile named `default`, the Edge Gateway creates one that does not verify the certificates of the targets. A profile whose TLS configuration fails is discarded, with an error in the log; a target that falls on no profile cannot be reached.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `sslconf` | — | a `default` profile without verification | TLS profile, repeatable. The profile named `default` applies to every target that matches no `hosts/host`. |
| `sslconf/@name` | `default` | required | Name of the profile, referenced by `hosts/host/@sslconf`. Missing or empty: the reading of the section stops, and the Edge Gateway keeps only a `default` profile without verification. |
| `sslconf/*` | `ca-dir=/etc/ssl/certs`, `verify-cert=true` | as for `<ssl>` | Each profile accepts the keys of `<ssl>`, applied to the connections to the targets: `cert` and `password` give a client certificate presented to the targets (optional), `ca-dir` and `ca-file` the authorities that verify their certificates, `verify-cert`, the versions and the cipher suites. `verify-certhostnamematch` acts only with `cert-peernames`, the address of the target never being used. Differences: an error on a file discards the profile instead of preventing the start; a profile that sets `ca-file` is discarded when `ca-dir` is not an existing directory. |
| `hosts/host` | — | — | Rule that assigns a profile to the targets matching `@target`. Repeatable; the first matching rule wins. |
| `hosts/host/@target` | — | required | Regular expression that must match the whole address of the target, as `<address>:<port>`. Missing, empty or invalid: the reading of the rules stops at that point. |
| `hosts/host/@sslconf` | — | required | Name of the profile applied. A name that matches no profile is reported in the log, and the rule is ignored. |

### `<webaccess>`

Processing of the web accesses, which the Edge Gateway carries out towards the web servers: authentication, proxies, rewriting of the pages, cookies. A `cache-folders` element without `permanent` and `temporary`, or a value of `compress-ipdivavars`, `inject-sso-component`, `prefer-ntlm-over-basic` or `use-cookiestore` that is not a boolean, stops the reading of the section at that point, and the following elements keep their default value.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `proxy` | empty | no proxy | HTTP proxy, as `<address>:<port>`, through which the Edge Gateway reaches the web servers, except the local loopback and the hosts of `proxy-exceptions`. |
| `proxy-exceptions/exception/pattern` | — | — | Pattern, with `*` wildcards, of a host reached without proxy, compared with the host requested, without port and in lowercase. `<exception>` is repeatable. |
| `antivirus` | — | — | Proxy used first, before `proxy`, for the web connections that are not HTTPS. |
| `useragent` | `true` | `true` | `false`: a `User-Agent` header containing `Mozilla` is cut at its first space before it is sent to the web server. |
| `autoauth` | `true` | `false` | `true`: enables the single sign-on of the web accesses: the Edge Gateway answers the authentication requests of the web servers with the credentials of the session. |
| `forcebasic` | `false` | `false` | `true`: adds a Basic authentication, built from the credentials of the session, to the requests that carry none. |
| `prefer-ntlm-over-basic` | — | `false` | `true`: when the web server offers Basic and NTLM, the single sign-on does not choose Basic. |
| `davenport` | `127.0.0.1:8070` | `127.0.0.1:8070` | Address of the WebDAV service: a request towards this address is processed as a WebDAV request. |
| `davenport/@compatibilityMode` | `false` | — | `true`: former WebDAV behaviour: the Edge Gateway announces to the Mediation Controller that it does not support the current WebDAV, and answers a WebDAV request with the code 303 instead of 200. |
| `max-http-100-continue` | — | `10` | Divisor of the size of a WebDAV request: after this fraction of the body, the Edge Gateway answers `100 Continue`. |
| `http` | — | `http` | Path segment with which the Edge Gateway rewrites the addresses of the HTTP services in the web pages. |
| `https` | — | `https` | Path segment with which the Edge Gateway rewrites the addresses of the HTTPS services in the web pages. |
| `cache-date` | `Thu, 14 Dec 2006 09:28:00 GMT` | — | Date before which the cache validations of the browsers are ignored: the Edge Gateway removes `If-Modified-Since` and `If-None-Match` from the older requests and sets `Last-Modified` on the responses concerned. |
| `max-content-data` | — | `10485760` | Size of a request body, in bytes, beyond which the Edge Gateway sends the headers without waiting for the body, and no longer keeps it for the single sign-on. |
| `reverse-proxy/headers/x-forwarded-for/@enabled` | `false` | `false` | `false`: the reverse proxy removes the `X-Forwarded-For` header from the requests it forwards to the web server. |
| `reverse-proxy/headers/x-forwarded-host/@enabled` | `false` | `false` | `false`: the reverse proxy removes the `X-Forwarded-Host` header from the requests it forwards to the web server. |
| `reverse-proxy/headers/api-info/@enabled` | — | `false` | `false`: the reverse proxy removes the headers prefixed with `X-IPdiva` from the requests it forwards to the web server. |
| `reverse-proxy/static-rewrite-engine/rewrite` | — | — | Rewriting rule applied by the reverse proxy to the body of the responses whose address matches `@urlpattern`. Repeatable; configured by the four attributes below. |
| `reverse-proxy/static-rewrite-engine/rewrite/@urlpattern` | — | empty | Regular expression searched in the full address of the request. An invalid expression discards the rule, with an error in the log. |
| `reverse-proxy/static-rewrite-engine/rewrite/@type` | — | `PLAIN` | `PLAIN`: `@pattern` is replaced literally; `REGEX`: `@pattern` is a regular expression, with groups. |
| `reverse-proxy/static-rewrite-engine/rewrite/@pattern` | — | empty | Text or regular expression searched in the body of the response. An invalid expression leaves the body unchanged, with an error in the log. |
| `reverse-proxy/static-rewrite-engine/rewrite/@replace` | — | empty | Replacement text of the occurrences of `@pattern`. |
| `webaccessjs` | — | `webaccess.js` | Name of the script injected into the web pages, served under `/static/gateway/`. When the main version of the package changes, the update empties this value. |
| `inject-sso-component` | — | `true` | `true`: injects the single sign-on script `/static/gateway/sso-injector.js` into the web pages, before the script of `webaccessjs`. |
| `compress-ipdivavars` | — | `true` | `true`: the `IPdiva-Vars` cookie is compressed, under the name `IPdiva-Vars-z`. |
| `rewrite-exclusions/domain` | — | — | Domain whose addresses the Edge Gateway leaves as they are in the web pages. Repeatable. |
| `js-parser` | — | `ng` | Analyzer of the JavaScript of the pages: `ng` loads the library named by `webaccess-path` and `libipdiva-parse`, `legacy` keeps only the former analyser. Any other value is reported in the log and means `ng`. |
| `webaccess-path` | — | `/usr/local/ipdiva/webaccess/` | Directory of the analysis library loaded when `js-parser` is `ng`. |
| `libipdiva-parse` | — | `libipdiva_parse.so` | Name of the analysis library loaded when `js-parser` is `ng`. If it cannot be loaded, the Edge Gateway falls back to the former analyser. |
| `js-delegate-browser` | — | `fallback` | With the former analyser: `always` always delegates the analysis to the browser, `fallback` only when the analysis fails, `disabled` never. Case does not matter; any other value is reported in the log and means `fallback`. |
| `use-cookiestore` | `true` | `true` | `true`: the Edge Gateway keeps the cookies of the web servers in its own store, in `/var/ipdiva/gateway/cookiestore/<edge-gateway>`, shared by the instances of a cluster. If the store cannot be opened, the Edge Gateway logs it and falls back to the former cookie handling. |

### `<vlan>`

Network interface through which the Edge Gateway opens its connections to the target servers. Loopback addresses are never concerned.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `prefixe` | empty | `eth0` | Interface used for a session that carries a VLAN number: the Edge Gateway connects through `<prefixe>.<number>`. Empty: the session uses the usual route. In version 4.7, only the first name of a list is tried. |
| `fixedvlan` | — | empty | Interface through which every connection to a target server goes, whatever the VLAN of the session. Takes precedence over `prefixe`. |

### `<socket>`

Options applied to the sockets of the Edge Gateway.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `recv-timeout` | — | `90000` | Reception timeout, in milliseconds. |
| `send-timeout` | — | `90000` | Sending timeout, in milliseconds. |
| `nodelay` | — | `true` | `true`: disables the grouping of small TCP segments (`TCP_NODELAY` option). |
| `selectmethod` | — | `auto` | Method used to wait for activity on the sockets: `select`, `poll` or `auto`. Case does not matter. |

### `<license>`

Licence of the Edge Gateway, former mode. It is absent from the template and the pairing removes it: the Edge Gateway then identifies itself by the common name of its certificate. When the element is present, even empty, the Edge Gateway works in licence mode: identity, Mediation Controller, authorised MAC addresses, number of sessions and throughput come from the licence, read from `data` or else from the licence file. A licence that cannot be read, or an XML licence without signature, prevents the start.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `data` | — | — | Content of the licence, covered by the signature. It must not be modified. |
| `signature` | — | the Edge Gateway does not start (XML licence) | Signature of the licence. |
| `license` | — | `gateway.lic`, next to `gateway.xml` | Path of the licence file, read when `data` is empty, and watched by `periodic-licence-check`. |

### `<debugger>`

Debug console of the Edge Gateway, configured through attributes.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `@enabled` | — | `false` | `true` (case does not matter): the Edge Gateway opens a debug console, without authentication, which answers text commands on the address of `bindAddress`. |
| `@bindAddress` | — | — | Listening address of the debug console, read only when `enabled` is `true`. |

## Applying a change

Restart the Edge Gateway:

```
1
```

An additional instance (see “One directory per instance” at the top of the page) is restarted by its own service, named after the instance:

```
1
```

To check that the link comes back up, see [Check the Edge Gateway connection to the controller](https://docs.cyberelements.io/saas/no/HowTo/CheckTheEdgeGatewayConnectionToTheController/).

> **The restart cuts the sessions carried by this Edge Gateway**
>
> Every session passing through this Edge Gateway is interrupted. When several Edge Gateways serve the same site, restart them one at a time.

## Upgrade

No package delivers the file, so an upgrade does not overwrite it and asks you nothing about it. It does touch it, though:

- it sets the owner `ipdivagateway:ipdivagateway` and the permissions `400` again;
- when the major version of the product changes, it empties the `webaccessjs` element of every `gateway.xml` (the one of each instance included) after saving the file as `gateway.xml.bak.<date>`: the web access script named there is not delivered by the new version.
