Installing Secure Mail Gateway
If the Secure Mail Gateway is used, the Secure Mail Gateway standalone service is a mandatory component starting with Relution 26.4.0. This article covers the setup for on-premise installations.
For configuring the Secure Mail Gateway in Relution: Secure Mail Gateway →
Technical background
If the Secure Mail Gateway is enabled under Settings → Device Management → Secure Mail Gateway, incoming ActiveSync connections are forwarded to the Exchange server configured there, provided the request originates from a permitted (enrolled) device.
In version 26.3.x and older, ActiveSync requests first reach the Relution service, which forwards them to the Exchange server. The Relution service checks internally whether a request originates from a permitted device and may be forwarded. Requests that are not permitted are rejected.
As of version 26.3.0, the standalone service can optionally be enabled in order to test the switch to the dedicated container in advance. As of version 26.4.0 and newer, the corresponding functionality has been removed from Relution entirely, which means ActiveSync requests always have to be routed through the dedicated Docker container.
The configuration required for this is described below.
Migration — What Needs to Be Done?
| Installation | Action required |
|---|---|
| Relution Cloud – Shared Hosting | No action required. Relution handles the migration of the SMG service. |
| Relution Cloud – Dedicated Server (existing customers) | Relution will host the SMG service. We will reach out to coordinate the migration. |
| Relution Cloud – Dedicated Server (new customers) | The SMG service must be operated as a self-hosted on-premise component. Follow the setup guide further down in this article. |
| On-Premise | The full setup process is described further down in this article. |
Feature toggle for on-premise installations (26.3)
New in Relution 26.3In Relution 26.3, on-premise installations can optionally activate the new mode. To do so, the following preview feature toggle has to be added to the Relution server’s application.yml:
relution:
featuretoggle:
enabledPreviewFeatures:
- SMG_STANDALONE
In addition, a further Docker container has to be added to the Docker environment as described below.
Mandatory component as of 26.4.0
New in Relution 26.4With Relution 26.4.0 the toggle is dropped. The Secure Mail Gateway must be operated as a separate service. The component has been removed from Relution entirely.
Setup
As an HTTP proxy, the Secure Mail Gateway standalone service forwards ActiveSync requests from mobile devices to the Exchange server and the responses back to the respective mobile device. To do so, it first has to be determined whether a request may be forwarded at all. So that the Secure Mail Gateway can make this decision, it has to communicate internally with the Relution service in order to check whether a request originates from a permitted device.
Relution
For the Secure Mail Gateway to be able to communicate with the Relution service, a technical user with the corresponding permissions has to be created in Relution first.
1. Create a Dynamic Role in Relution
The ready-made role template can be downloaded and imported in the Global organisation under Users → Permissions:
Alternatively, the role can be created manually:
- Navigate to
Users→Permissionsin the Global organisation - Add a new Dynamic Role
- Enable the Secure Mail Gateway (service account) permission
- Save the role
2. Create a technical user and access token
Create a new user in the Global organisation and assign the Dynamic Role created above
Open the user’s detail page and, in the Access tokens section, create a new access token via Add: under Usage, select the API option and, in the API scopes field, enable the Secure Mail Gateway (smg) entry. Only Management portal (management) is preselected; the Secure Mail Gateway does not need this scope.

Choose an Expiration Date. API access tokens always expire. The date is preset to today plus the default lifetime (30 days by default). As of Relution 27.0.1, any date up to the maximum lifetime (1 year by default) can be chosen; the dialog shows the latest possible expiration date. As of Relution 26.5.7, the Limited time of use toggle is no longer shown for API tokens; up to Relution 26.5.6, a token with the toggle disabled expired after the default lifetime of 30 days. The default lifetime also applies to API tokens requested without an expiration date and can be adjusted via
relution.security.access-token.default-lifetime, the maximum lifetime viarelution.security.access-token.max-lifetime.Copy the generated token — it is only shown once
As of Relution 26.5, an API access token is only valid for the selected API scopes. The Secure Mail Gateway requires the Secure Mail Gateway (smg) scope. If it is missing, Relution rejects the Secure Mail Gateway’s requests (HTTP 403): it can then neither check devices nor load settings. If a list of allowed API scopes (relution.api.scope.enabled-scopes) is set in the Relution server configuration, it must contain smg.
Once the access token has expired, the Secure Mail Gateway can no longer query Relution either; as of Relution 26.5.8, Relution answers such requests with HTTP 401 instead of HTTP 500. The expiration date cannot be changed after the token has been created; a token can only be replaced. In good time before the chosen expiration date, a new token is therefore created, entered in smg/application.yaml (relution.server.api-key), and the smg container is restarted.
API access tokens created before the update to Relution 26.5 automatically receive all API scopes during the update. Tokens without an expiration date expire 30 days after the update to Relution 26.5.5 and have to be replaced by then (SMG: access token expires 30 days after updating to 26.5.5 →). On PostgreSQL, this period only applies as of Relution 26.5.7: after the update to Relution 26.5.5 or 26.5.6, such tokens expired there immediately. Tokens that have already expired are recreated and entered in smg/application.yaml.
Secure Mail Gateway container
The Secure Mail Gateway now has to be added to the environment as a separate Docker container and configured. Afterwards, the reverse proxy has to be adjusted so that requests to the /Microsoft-Server-ActiveSync endpoint are no longer sent to the Relution container but to the Secure Mail Gateway container.
1. Deploy the service
The following service is added to the existing compose.yaml. This is only needed if the Secure Mail Gateway is used.
latest. New builds go through additional quality gates before being promoted to latest — pinning a specific version tag may result in running a build that has not yet been validated for production use.services:
…
smg:
image: relution/relution-smg-standalone:latest
restart: always
container_name: smg
networks:
- reverse-proxy
volumes:
- ./smg/application.yaml:/opt/app/config/application.yaml:ro
expose:
- 8093
Note: With expose, port 8093 is only reachable within the Docker network, in this case by nginx/Traefik, and is not published on the host. If the reverse proxy runs outside the Docker environment, expose has to be replaced with ports so that the port is published on the host:
services:
…
smg:
…
ports:
- 127.0.0.1:8093:8093
Binding to 127.0.0.1 limits the port to the host itself, which is sufficient if the reverse proxy runs natively on the same host. If the reverse proxy runs on a different machine, the port has to be published on all interfaces (8093:8093) and access restricted to the reverse proxy by a firewall — otherwise the SMG can be reached directly via unencrypted HTTP, bypassing the reverse proxy. Ports published by Docker are not covered by host firewalls such as ufw; the rules have to be added to the DOCKER-USER chain or applied on a network firewall.
smg must be on the reverse-proxy network like relution and traefik — otherwise Traefik/nginx cannot route to it.2. Configure the service
The access token created in Relution earlier has to be added to the Secure Mail Gateway configuration so that the SMG can communicate with the Relution service.
If both services run in the same compose.yaml on one server, they communicate internally via the Docker network.
smg/application.yaml is created alongside the compose.yaml:
relution:
server:
url: http://relution:8080 # Keep unchanged with a shared compose.yaml
api-key: your-api-key # Access token created above
URL of the Relution server: If the Secure Mail Gateway and Relution run in the same compose.yaml on one server, url: http://relution:8080 remains unchanged. The service name relution is then resolved via the shared Docker network.
The URL only needs to be changed if the SMG does not run in the same network as Relution, e.g. on a different server or in a separate compose.yaml with its own Docker network. In that case, the address at which Relution can be reached from the SMG is entered, e.g. https://relution.example.com.
Reverse proxy configuration
The SMG service exposes the /Microsoft-Server-ActiveSync endpoint on port 8093. The reverse proxy’s configuration must be updated to route incoming requests on this path to the standalone SMG service. The examples below show how to do this for Traefik and nginx.
If a different reverse proxy is used that is not officially supported (e.g. Apache, Sophos, …), its configuration has to be adjusted accordingly. The product’s documentation describes how individual paths or locations can be forwarded to separate endpoints.
Note: The examples below use hostnames that can be resolved within the Docker network. This is only possible while Relution, SMG and Traefik/nginx are part of the same Docker network. If reverse proxy or services are on separate networks, hostnames the internal DNS server can resolve must be used instead.
Traefik
The following additional smg entries are added below routers and services. Existing routers and services, such as relution, are kept. See also: Traefik configuration →
http:
routers:
…
smg:
rule: Host(`external.url`) && Path(`/Microsoft-Server-ActiveSync`)
entryPoints:
- websecure
tls:
certResolver: letsencrypt
service: smg
services:
…
smg:
loadBalancer:
servers:
- url: "http://smg:8093"
nginx (alternative to Traefik)
The location ~ /Microsoft-Server-ActiveSync block is added to (or updated in) the existing HTTPS server block so that incoming requests are forwarded to the SMG.
server {
listen 0.0.0.0:443 ssl default_server;
…
# (NEW) Redirect to Secure Mail Gateway
location ~ /Microsoft-Server-ActiveSync {
proxy_read_timeout 2100;
proxy_pass http://smg:8093;
}
}
The blocks position within the server block is not relevant, since nginx evaluates regular expression locations before the / prefix location. However, it is recommended to keep individual location blocks next to each other for the sake of readability.
smg refers to the Docker service name and is reachable within the Docker network. For a native Linux installation, smg:8093 is replaced with 127.0.0.1:8093.Start or restart the Docker services
For the changes to take effect, the Docker containers have to be restarted afterwards.
docker compose up -d
relution.smg.* properties were previously customised in the Relution server configuration, they have to be copied to this file unchanged — the property names are the same.Advanced configuration
The following settings are only required in specific environments — for Exchange servers with a private IP address, for internal certificate authorities and for outbound connections that have to go through a corporate proxy.
Forwarding to private IP addresses
New in SMG 26.0.7As of SMG 26.0.7, on-premise deployments whose Exchange server resolves to a private IP address (RFC 1918 →) must configure it as an allowed target address.
- The following IP addresses are blocked by default:
- loopback
- link-local (including cloud metadata at 169.254.169.254)
- private ranges (10/8, 172.16/12, 192.168/16)
- IPv6 unique-local (fc00::/7)
- carrier-grade NAT (100.64/10)
- multicast
- 0.0.0.0
- It is recommended to allow individual IP addresses or address ranges over host names. When a host name is allowed, the address check is skipped, regardless of the IP it resolves to. Allowing by IP address or range is stricter, because the check runs against the address a name resolves to.
- Invalid ranges: a malformed CIDR entry, such as
10.0.0.0/33, prevents service startup with an error naming the bad entry. - Disabling: with
block-non-public-addresses: false, the gateway logs a startup warning that this is a security risk. The allowlist is the recommended alternative.
Allow individual IP addresses (recommended)
relution:
smg:
target-policy:
allowed-targets:
- 192.168.10.25
- 192.168.10.26
- 10.20.0.5
- …
Allow network ranges (CIDR)
relution:
smg:
target-policy:
allowed-targets:
- 10.20.0.0/16
- fd12:3456:789a::/48
- …
Allow by hostname
relution:
smg:
target-policy:
allowed-targets:
- exchange.corp.example.com
Disable protection (not recommended)
relution:
smg:
target-policy:
block-non-public-addresses: false
Blocked requests
When a request is blocked by this policy, the device receives an HTTP 502 status response, and the gateway logs a WARN line. That line names the host, the address it resolved to and the category.
(Optional) Trusting a custom CA certificate
If the Exchange server presents a server certificate issued by an internal CA (“self-signed”), the root certificate of that CA has to be added as a trusted certificate. To do so, a directory containing the PEM-encoded certificate file can be mounted into the container at /opt/app/ca-certs. The folder may contain more than one certificate if required.
services:
…
smg:
volumes:
- ./smg/application.yaml:/opt/app/config/application.yaml:ro
- ./smg/ca-certs:/opt/app/ca-certs:ro
These certificates are used when communicating with the Exchange and Relution server — there is no configuration property to set. If nothing is mounted, the feature is a no-op and outbound TLS behaves exactly as before. Adding, removing, or changing a certificate requires restarting the container; the directory is only read once, at startup. The certificate files must be readable by app-user, the user the container runs as (e.g. chmod 644 on the host); otherwise no certificate is loaded and a warning is logged at startup.
(Optional) Proxy for outbound connections
Requests to Exchange honor the JVM’s proxy system properties. These are set via JAVA_TOOL_OPTIONS in the compose.yaml for the SMG container. The honor-proxy-settings flag in smg/application.yaml is not required for this; it only controls whether requests to the Relution server also go through the proxy (see below).
services:
…
smg:
environment:
- JAVA_TOOL_OPTIONS=
-Dhttp.proxyHost=proxy.example.com
-Dhttp.proxyPort=3128
-Dhttps.proxyHost=proxy.example.com
-Dhttps.proxyPort=3128
-Dhttp.nonProxyHosts=relution|example.com
With -Dhttp.nonProxyHosts (a |-separated list of host patterns, * wildcards supported) specific hosts can be excluded from the proxy — typically Exchange itself, if it is reachable directly without going through the corporate proxy.
By default, calls to the Relution server are not proxied — it is normally reachable directly. If the deployment reaches Relution through the same proxy as Exchange, honor-proxy-settings: true has to be set in smg/application.yaml:
relution:
server:
url: https://your-relution-server
api-key: your-api-key
honor-proxy-settings: true # default false; only needed if Relution is also behind the proxy
Troubleshooting
If issues occur with the SMG service — for example connecting to Exchange or starting the container — increasing the log level helps with the analysis. The Secure Mail Gateway is a separate service: the methods described in Set log level → (Web API, system portal, application.yml of the Relution server) do not affect the SMG container, and its log is not part of the Relution log file.
The log level is enabled in the SMG container via its application.yaml by appending the following section at the end and then restarting the container:
logging:
level:
io.relution: DEBUG
To analyze the HTTPS communication with the Exchange server, org.apache.hc.client5.http.wire: DEBUG can be set in addition. This wire log contains the complete requests including the credentials, so the entry is removed again after the analysis. A detailed procedure is described in Local Exchange with Secure Mail Gateway →.
docker logs smg shows the container’s logs. At startup, the Secure Mail Gateway logs every CA certificate it loads (Trusting custom CA certificate from …). If it rejects a server’s certificate chain, the chain presented by the server is logged as well (Server certificate chain rejected for …).
For monitoring, the container provides a health endpoint (/actuator/health, including /actuator/health/liveness and /actuator/health/readiness) and Prometheus metrics (/actuator/prometheus) on the internal management port 8099.
Changelog
The changes in each version are listed in the Secure Mail Gateway Changelog →.