Configure a Sync Gateway Install

      +

      Configure your Sync Gateway installation; securely sync enterprise data from cloud to edge!
      This is Step 3 in the Start Here! topic group. Here you’ll configure sync gateway to connect to a Couchbase Server instance and verify that the connection is working.

      Preparatory Steps
      Make sure you have read and acted-upon the information and steps in Prepare and Install before proceeding.

      These instructions are for local or server based deployments. If you’re using a container such as Docker, see this blog post on using Docker with Couchbase Mobile for additional details.

      Steps in Getting Started

      Introduction | Prepare | Install | Configure

      Introduction

      In this step of the Getting Started topic we will configure your Sync Gateway to connect to a Couchbase Server instance and verify that the connection is working.

      You’ll need to edit the configuration file used in the Install step to point to a bucket on your Couchbase Server — see Bootstrap Sync Gateway.

      On completion of this topic you’ll have a working sync gateway instance connected to Couchbase Server. You can then continue to Explore to add a database, create users, and run a CRUD cycle.

      Bootstrap Sync Gateway

      To configure sync gateway to connect to a Couchbase Server:

      1. Make sure your sync gateway service stops/unloads

      2. Edit the configuration file you used in Install and replace the contents with those shown in Example 1.

        The configuration points to your Couchbase Server cluster, which you’ll use to verify that you can connect to Couchbase Server through sync gateway.

      3. Make sure you start Couchbase Server

      4. Restart/Load your sync gateway to pick-up the changed configuration

      Example 1. Simple Sync Gateway Bootstrap Config
      {
        "bootstrap": {
          "server": "couchbases://localhost", (1)
          "username": "sync_gateway", (2)
          "password": "password",
          "server_tls_skip_verify": true, (3)
          "use_tls_server": true (4)
        },
        "logging": { (5)
          "console": {
            "enabled": true,
            "log_level": "info",
            "log_keys": ["*"]
          }
        }
      }

      About the Configuration Properties:

      1 Here you’ll point to the Couchbase Server cluster using secure connection. Server ships with self-signed certs that work out of the box, as long as server_tls_skip_verify is set, as it’s below.
      2 Here you’ll provide the credentials for the RBAC user that you created on the Couchbase Server Admin Console — see Configure Server for Sync Gateway
      3 Here you’ll opt to ignore CA Cert verification of the certificate presented by the server; allowing for example use of self-signed certificate. The connection is unverified but encrypted.
      4 Optionally, you can choose to run without TLS by setting this value to false. In that case you should also use the plaintext URI couchbase://localhost to connect.
      5 Define your logging requirements.
      Here you’ll set general diagnostic console logs on. If you’re having issues, for more information, see Logging for how to tune diagnostics to provide additional troubleshooting help.
      Start Sync Gateway

      Run the following in a terminal:

      bin/sync_gateway -<options> sgwconfig.json (1)
      1 Optionally provide any CLI flags you require to use.

      Connect to Sync Gateway

      You can use Console Logs to aid diagnosis of connection issues.
      1. With sync gateway and Couchbase Server started, point your browser to the sync gateway url, typically on port 4984, but this can be changed — see: REST API Access.

        So, for example:

        http://localhost:4984
      2. Check that you receive a response similar to this:

        {"couchdb":"Welcome","vendor":{"name":"Couchbase Sync Gateway","version":"4.0"},"version":"Couchbase sync gateway/{version-full}(376;e2e7d42) EE"}

        If there are issues, check the Console Logs for more information. Where necessary you can redirect console output to a file — see: Redirect Console Logs.

      If sync gateway is behind a load balancer, check the websockets configuration — see Load Balancer.

      Next Steps

      Now that you have a configured sync gateway installation connected to Couchbase Server, continue to Explore page, where you’ll add a database configuration, create users, and run a CRUD cycle to confirm sync is working end-to-end.

      From there, you can explore more complex scenarios with confidence: