dockerserverdnsminiocaddy

Unable to access Minio console on my private server


I am unable to access Minio console on my private server, I intend to run two containers of Minio.

docker-compose.yaml

version: '3.8'

services:
  minio_server_one:
    image: minio/minio:latest
    restart: always
    container_name: minio_server_one
    volumes:
      - ./minio/data:/data
    expose:
      - 9000
      - 9091
    environment:
      MINIO_ROOT_USER: ${MINIO_ROOT_USER_ONE}
      MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD_ONE}
      MINIO_BROWSER_REDIRECT_URL: http://stash-one.localhost
    command: "server /data --console-address ':9090'"

  minio_server_two:
    image: minio/minio:latest
    restart: always
    container_name: minio_server_two
    volumes:
      - ./minio/data:/data
    expose:
      - 9001
      - 9092
    environment:
      MINIO_ROOT_USER: ${MINIO_ROOT_USER_TWO}
      MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD_TWO}
      MINIO_BROWSER_REDIRECT_URL: http://stash-two.localhost
    command: "server /data --console-address ':9093'"  

  caddy_reverse_proxy:
      container_name: caddy_reverse_proxy
      image: caddy:alpine
      restart: always
      ports:
        - 80:80      
        - 443:443
      environment:
        - EXT_ENDPOINT1=${EXT_ENDPOINT1}
        - LOCAL_1=${LOCAL_1}
        - LOCAL_2=${LOCAL_2}
      volumes:
        - ./caddy/Caddyfile:/etc/caddy/Caddyfile
        - ./static:/code/static
        - caddy_data:/data
        - caddy_config:/config

volumes:
  caddy_data:
  caddy_config:

I am using Caddy as well.

Caddyfile

{$EXT_ENDPOINT1} should refer to mybeautifuldomain.com.

storage-one.{$EXT_ENDPOINT1}, storage-one.{$LOCAL_1}, storage-one.{$LOCAL_2} {
  reverse_proxy minio_server_one:9000 
}

stash-one.{$EXT_ENDPOINT1}, stash-one.{$LOCAL_1}, stash-one.{$LOCAL_2} {
  reverse_proxy minio_server_one:9090 
}

storage-two.{$EXT_ENDPOINT1}, storage-two.{$LOCAL_1}, storage-two.{$LOCAL_2} {
  reverse_proxy minio_server_two:9001 
}

stash-two.{$EXT_ENDPOINT1}, stash-two.{$LOCAL_1}, stash-two.{$LOCAL_2} {
  reverse_proxy minio_server_two:9093 
}

.env

#############################################
# Caddy variables
#############################################
EXT_ENDPOINT1=mybeautifuldomain.com
LOCAL_1=localhost
LOCAL_2=127.0.0.1

#############################################
# Minio variables
#############################################
MINIO_URL_ONE=storage-one.localhost
MINIO_BUCKET_ONE=minio-one
MINIO_ROOT_USER_ONE=minioadmin
MINIO_ROOT_PASSWORD_ONE=SECRETSECRET

#############################################
# Minio variables
#############################################
MINIO_URL_TWO=storage-two.localhost
MINIO_BUCKET_TWO=minio-two
MINIO_ROOT_USER_TWO=minioadmin
MINIO_ROOT_PASSWORD_TWO=SECRETSECRET

When I tested it locally by running docker compose up, I can access the console on both stash-one.localhost and stash-two.localhost.

I have also, via GoDaddy, set up my DNS Record as such, for stash-one, stash-two, storage-one and storage-two, like so:

enter image description here

Even then, I am still unable to access the console on my website, say, mybeautifuldomain.com.

enter image description here


Solution

  • I managed to solve my own issue with the following modifications to the docker-compose.yaml and Caddyfile as follows:

    docker-compose.yaml

    version: '3.8'
    
    services:
      minio_server_one:
        image: minio/minio:latest
        restart: always
        container_name: minio_server_one
        volumes:
          - ./minio/data-one:/data # ensuring container is mirroring a different volume
        expose:
          - 9000 # ensuring it is not used by `minio_server_two`
          - 9091 # ensuring it is not used by `minio_server_two`
        environment:
          MINIO_ROOT_USER: ${MINIO_ROOT_USER_ONE}
          MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD_ONE}
          MINIO_BROWSER_REDIRECT_URL: http://stash-one.${EXT_ENDPOINT1}
        # the most important change is HERE
        # instead of http://stash-one.localhost
        # change this to http://stash-one.${EXT_ENDPOINT1}
        # note the domain prefix is unique as well
        command: "server /data --console-address ':9090'"
        # make sure the ':9090' ports are unique for minio_server_one and two
    
      minio_server_two:
        image: minio/minio:latest
        restart: always
        container_name: minio_server_two
        volumes:
          - ./minio/data-two:/data # ensuring container is mirroring a different volume
        expose:
          - 9001 # ensuring it is not used by `minio_server_one`
          - 9092 # ensuring it is not used by `minio_server_one`
        environment:
          MINIO_ROOT_USER: ${MINIO_ROOT_USER_TWO}
          MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD_TWO}
          MINIO_BROWSER_REDIRECT_URL: http://stash-two.${EXT_ENDPOINT1}
        command: "server /data --console-address ':9093'"  
    
      caddy_reverse_proxy:
          container_name: caddy_reverse_proxy
          image: caddy:alpine
          restart: always
          ports:
            - 80:80      
            - 443:443
          environment:
            - EXT_ENDPOINT1=${EXT_ENDPOINT1}
            - LOCAL_1=${LOCAL_1}
            - LOCAL_2=${LOCAL_2}
          volumes:
            - ./caddy/Caddyfile:/etc/caddy/Caddyfile
            - ./static:/code/static
            - caddy_data:/data
            - caddy_config:/config
    
    volumes:
      caddy_data:
      caddy_config:
    

    Caddyfile

    storage-one.{$EXT_ENDPOINT1}, storage-one.{$LOCAL_1}, storage-one.{$LOCAL_2} {
      reverse_proxy minio_server_one:9000
      # state exactly the name of the container `minio_server_one`
      # the port should be the first exposed port in `docker-compose.yaml`
    }
    
    stash-one.{$EXT_ENDPOINT1}, stash-one.{$LOCAL_1}, stash-one.{$LOCAL_2} {
      reverse_proxy minio_server_one:9090
      # the `stash-one` prefix should point to the port declared in the
      # command segment of the `docker-compose.yaml` file
      # e.g. command: "server /data --console-address ':9090'"
      #                                                ^^^^^
    }
    
    storage-two.{$EXT_ENDPOINT1}, storage-two.{$LOCAL_1}, storage-two.{$LOCAL_2} {
      reverse_proxy minio_server_two:9001 
    }
    
    stash-two.{$EXT_ENDPOINT1}, stash-two.{$LOCAL_1}, stash-two.{$LOCAL_2} {
      reverse_proxy minio_server_two:9093 
    }