Skip to main content

Reverse proxy (Traefik, nginx, etc)

See also:

HTTP(S) Failover Concepts for REST, OPC UA Server, and WebManagement in the OPC Router

To run OPC Router in Docker behind a reverse proxy such as Traefik or nginx, a few settings must be configured. Please note that OPC Router uses both HTTP and WebSocket connections, which must be forwarded correctly by the reverse proxy.

note

This section only describes the steps necessary for web management. Further adjustments may be necessary for the REST server or other plug-ins.

tip

To optimize network performance, we recommend enabling SSL offloading in the reverse proxy rather than in OPC Router when using a reverse proxy. This is especially true if the network traffic between the reverse proxy and OPC Router can be considered secure.

Path Prefix​

To access the OPC Router via a reverse proxy with a path prefix, two environment variables must be set. The environment variable WEB_BASE_PATH specifies the path prefix used by the reverse proxy; the value must begin with a forward slash. The environment variable ASPNETCORE_FORWARDEDHEADERS_ENABLED must be set to true so that the OPC Router can process the header information passed by the reverse proxy. Both variables are described in Configurable Environment Variables.

Example Traefik configuration:

docker run ... \
-e "WEB_BASE_PATH=/opc-router" \
-e ASPNETCORE_FORWARDEDHEADERS_ENABLED=true \
--label "traefik.http.routers.reverse-proxy.rule=PathPrefix(`/opc-router`)"

Hostname​

To make the OPC Router accessible under a specific hostname, you can set up a reverse proxy. You must ensure that the reverse proxy host itself is accessible under the specified DNS address. In addition, the environment variable ASPNETCORE_FORWARDEDHEADERS_ENABLED must be set to true so that the OPC Router can correctly process the header information of the reverse proxy.

To ensure that the OPC Router knows the address at which it is accessible from the outside, enter it in OR_EXTERNAL_URI_PREFIX; additional addresses can be specified in OR_ADDITIONAL_EXTERNAL_URI_PREFIXES. Both are described under “Configurable Environment Variables.”