How do I connect redis and redis-insight containers on my network

1.6k Views Asked by At

I've written a .tf file that spins up a redis and redis-insight container in their private docker network (openstack instance), but when I ngrok to redis-insight I get this error:

Redis-insight in browser

1

I can't seem to get the environment variables on the redis-insight resource right.

I've tried many combinations of the env vars in the redis-insight resource. Since I'm using ngrok for tunneling I set the RITRUSTEDORIGINS var to its port (http://localhost:4040) following the example of this page in the redis documentation that uses nginx as a proxy, but to no luck.

What environment variables should I be using on my redis-insight resource? This is what I have written so far:

terraform {
  required_providers {
    docker = {
      source  = "kreuzwerker/docker"
      version = "2.23.1"
    }
  } 
}

provider "docker" {}
resource "docker_network" "redis_network" {
  name = "redis_network"
}
resource "docker_image" "redis" {
  name         = "redis:latest"
  keep_locally = false
}

resource "docker_container" "redis" {
  image = docker_image.redis.image_id
  name  = "redis"
  ports {
    internal = 6379
    external = 6379
  }
  network_mode = docker_network.redis_network.name
}

resource "docker_image" "redis-insight" {
  name         = "redislabs/redisinsight:latest"
  keep_locally = false
}

resource "docker_container" "redis-insight" {
  image = docker_image.redis-insight.image_id
  name  = "redis-insight"
  ports {
    internal = 8001
    external = 8001
  }
  network_mode = docker_network.redis_network.name
  depends_on = [docker_container.redis]
  env = [
    "REDIS_URL=redis://redis:6379",
    "REDIS_PASSWORD=password",
#    "REDIS_DATABASE=1",
#    "REDIS_TLS=true",
#    "INSIGHT_DEBUG=true",
#    "RIPORT=8001",
#    "RIPROXYENABLE=t",
    "RITRUSTEDORIGINS=http://localhost:4040"
  ]
}
1

There are 1 best solutions below

0
On

Whats the hostname and port of RedisInsight you are accessing from your browser? If its not localhost:4040, set that in RITRUSTEDORIGINS.

If it is localhost:4040, set RITRUSTEDORIGINS to http://localhost:4040.

Set the right protocol (http or https), hostname and port. This should match the one you use in browser.