Skip to main content
Version: 5.6

Docker Compose Example for Redundancy and Failover with Nginx

The Nginx configurations described on the Redundancy and Failover with Nginx page can be used in Docker Compose to deploy a redundant OPC Router pair with failover.

The files used as the project are located on the HTTP(s) Failover Concepts for REST, OPC UA Servers, and Web Management in the OPC Router page.

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.

docker-compose.yaml
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 lizenz="" 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=SuperSecret123
- OR_REDUNDANCY_MODE=primary
- OR_REDUNDANCY_LOCAL_MANAGEMENT_ADDRESS=http://opcrouter-primary:8080
- OR_REDUNDANCY_SHARED_KEY=LUyLxk4kZdvYW9kM6ZSBWbBatdj9RGow9Bp
- OR_IMPORT_SOURCE=/inray/REST_Primary.rpe
volumes:
# Make the project available in the 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=SuperSecret123
- OR_REDUNDANCY_MODE=secondary
- OR_REDUNDANCY_SHARED_KEY=LUyLxk4kZdvYW9kM6ZSBWbBatdj9RGow9Bp
- 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:
# Make the project available in the container
- ../REST_Secondary.rpe:/inray/REST_Secondary.rpe

networks:
opcrouter-net:

```</nginx></tag>