You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Docker Compose配置Realm Object Server数据适配器遇HTTPS连接问题

Let's walk through fixing this HTTPS connection issue between your Data Adapter and Realm Object Server (ROS) in your Docker Compose setup—this is a common gotcha when working with containerized Realm services.

  • Confirm ROS is configured for HTTPS and ports are exposed correctly
    First, ROS needs to have HTTPS enabled. You can either use self-signed certificates (auto-generated by ROS if you don't provide your own) or mount custom certificates. Update your docker-compose.yml for the ROS service to ensure:

    • The HTTPS port (default 9080) is exposed
    • Environment variables enable HTTPS (and point to certs if using custom ones)
      Example ROS service config:
    services:
      ros:
        image: realm/realm-object-server:latest
        ports:
          - "9080:9080"  # HTTPS port
          - "9081:9081"  # Optional HTTP admin port
        environment:
          - REALM_SERVER_HTTPS_ENABLED=true
          # Uncomment below if using custom certs
          # - REALM_SERVER_HTTPS_CERT_PATH=/certs/cert.pem
          # - REALM_SERVER_HTTPS_KEY_PATH=/certs/key.pem
        volumes:
          # Mount custom certs directory if needed
          # - ./local-certs:/certs
    
  • Fix the Data Adapter's ROS connection URL
    The error you're seeing means your adapter is trying to connect without specifying the https:// protocol, or using an invalid URL format. Make sure the adapter's configuration uses a full HTTPS URL pointing to the ROS service name (Docker Compose lets services communicate via their service names).

    • In your adapter code, set the server URL explicitly:
      const realm = require('realm');
      const dataAdapter = new realm.DataAdapter({
        serverUrl: 'https://ros:9080', // Critical: include https:// prefix
        // Other adapter config (auth, etc.)
      });
      
    • Or pass the URL via an environment variable in your docker-compose.yml for the adapter service:
      services:
        ros-adapter:
          build: ./your-adapter-directory
          environment:
            - ROS_SERVER_URL=https://ros:9080
          depends_on:
            - ros
      
  • Handle self-signed certificate trust (for development)
    If ROS is using a self-signed certificate (the default), Node.js (which your Data Adapter runs on) will reject the connection by default. You have two options here:

    1. Trust the ROS certificate (recommended for development, required for production):
      • Copy the ROS-generated certificate to your adapter container and set the NODE_EXTRA_CA_CERTS environment variable to point to it. Update your adapter's compose config:
        ros-adapter:
          # ... other config
          volumes:
            - ./ros-certs/ros-cert.pem:/usr/src/app/ros-cert.pem
          environment:
            - ROS_SERVER_URL=https://ros:9080
            - NODE_EXTRA_CA_CERTS=/usr/src/app/ros-cert.pem
        
      Note: You can get the auto-generated cert from the ROS container by running docker cp ros_1:/var/lib/realm/certs ./ros-certs
    2. Temporarily disable certificate validation (only for local development, never use in production):
      Add this line at the very top of your adapter's entry file:
      process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
      
  • Verify Docker network connectivity
    Ensure both ROS and the Data Adapter are on the same Docker network (Docker Compose creates a default network for all services in the file, so this should be true unless you've customized networks). To confirm, run:

    docker exec -it ros-adapter_1 ping ros
    

    If the ping fails, explicitly define a network in your docker-compose.yml and attach both services to it:

    networks:
      ros-internal:
        driver: bridge
    
    services:
      ros:
        # ... other config
        networks:
          - ros-internal
      ros-adapter:
        # ... other config
        networks:
          - ros-internal
    
  • Check ROS logs to confirm HTTPS is running
    Finally, make sure ROS actually started the HTTPS server. Check the ROS container logs with:

    docker logs ros_1
    

    Look for a line like HTTPS server listening on port 9080 to confirm HTTPS is active.

内容的提问来源于stack exchange,提问作者Artur Miranda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:19:23