Running a Redundant Pair Behind Nginx – Docker Compose Example
The Nginx configurations described on the Redundancy and Failover with Nginx page can be used in Docker Compose to deploy an OPC router redundancy pair with failover.
The files used for this project can be found on the page HTTP(S) Failover Concepts for REST, OPC UA Servers, and Web Management in the OPC Router.
This example deals exclusively with the external reverse proxy for the server endpoints. The internal redundancy of the OPC Router must be configured separately for the primary and secondary services.
The password and pre-shared key are shown here as placeholders. Do not enter these values in plain text in a Compose file that will be version-controlled—the pre-shared key applies to both instances and is the key to the redundancy connection. Instead, use the OPC Router’s secrets store. You can generate the pre-shared key by clicking the “Generate” button in the “Pre-Shared Key” section; see “Secure Redundancy.”
services:
nginx_plus:
# Nginx Plus
image: private-registry.nginx.com/nginx-plus/base:<Tag>
# Alternatively, Nginx
# image: nginx:latest
restart: always
networks:
- opcrouter-net
ports:
- "5080:80"
environment:
# Required only for Nginx Plus
- NGINX_LICENSE_JWT=<nginx-license-jwt>
volumes:
# Make nginx.conf available in the container
- ./nginx.conf:/etc/nginx/nginx.conf:ro
opcrouter-primary:
image: opcrouter/service:latest
restart: always
networks:
- opcrouter-net
ports:
- "5085:8080"
environment:
- OR_I_ACCEPT_EULA=true
- INITIAL_USERNAME=admin
- INITIAL_PASSWORD=<your-password>
- OR_REDUNDANCY_MODE=primary
- OR_REDUNDANCY_LOCAL_MANAGEMENT_ADDRESS=http://opcrouter-primary:8080
- OR_REDUNDANCY_SHARED_KEY=<your-pre-shared-key>
- OR_IMPORT_SOURCE=/inray/REST_Primary.rpe
volumes:
# Making the Project Available in a Container
- ../REST_Primary.rpe:/inray/REST_Primary.rpe
opcrouter-secondary:
image: opcrouter/service:latest
restart: always
networks:
- opcrouter-net
ports:
- "5086:8080"
environment:
- OR_I_ACCEPT_EULA=true
- INITIAL_USERNAME=admin
- INITIAL_PASSWORD=<your-password>
- OR_REDUNDANCY_MODE=secondary
- OR_REDUNDANCY_SHARED_KEY=<your-pre-shared-key>
- OR_REDUNDANCY_ADDRESS=http://opcrouter-primary:8080
- OR_REDUNDANCY_LOCAL_MANAGEMENT_ADDRESS=http://opcrouter-secondary:8080
- OR_REDUNDANCY_PRIMARY_TIMEOUT=30
- OR_REDUNDANCY_SECONDARY_HEARTBEAT_INTERVAL=10
- OR_IMPORT_SOURCE=/inray/REST_Secondary.rpe
volumes:
# Making the Project Available in a Container
- ../REST_Secondary.rpe:/inray/REST_Secondary.rpe
networks:
opcrouter-net: