dockerhttpswebsocketcaddymattermost

Secure mattermost connection by Caddy but websocket is not work


I am trying to secure my mattermost connection through Caddy. The closest one comes from micheljung answer

The way web and app were configured didnt't make sense. Now it works. What I did:

Enable Let's Encrypt and Port 80 to 443 forwarding
Let app expose ports 80 and 443 (configure in Dockerfile and in docker-compose.yml)
Remove the web container because its only purpose was basically SSL, which is now handled by Mattermost
Profit!

I did followed his answer along. But not be able to use websocket feature Here is what I have tried

Caddyfile

chat.{$DOMAIN_NAME} {
    proxy / app:8000
}

Dockerfile

FROM abiosoft/caddy:0.11.2

COPY Caddyfile /etc/Caddyfile

docker-compose.yml

version: "2"

services:

  db:
    build: db
    read_only: true
    restart: unless-stopped
    volumes:
      - ./volumes/db/var/lib/postgresql/data:/var/lib/postgresql/data
      - /etc/localtime:/etc/localtime:ro
    environment:
      - POSTGRES_USER=mmuser
      - POSTGRES_PASSWORD=mmuser_password
      - POSTGRES_DB=mattermost

  app:
    build:
      context: app
      args:
        - edition=team
    restart: unless-stopped
    volumes:
      - ./volumes/app/mattermost/config:/mattermost/config:rw
      - ./volumes/app/mattermost/data:/mattermost/data:rw
      - ./volumes/app/mattermost/logs:/mattermost/logs:rw
      - ./volumes/app/mattermost/plugins:/mattermost/plugins:rw
      - ./volumes/app/mattermost/client-plugins:/mattermost/client/plugins:rw
      - /etc/localtime:/etc/localtime:ro
    expose:
      - 8000
    environment:
      # set same as db credentials and dbname
      - MM_USERNAME=mmuser
      - MM_PASSWORD=mmuser_password
      - MM_DBNAME=mattermost

  caddy:
    build:
      context: .
      dockerfile: Dockerfile
    depends_on:
      - app
    volumes:
      - production_caddy:/root/.caddy
    environment:
      - DOMAIN_NAME=unicornonzen.com
    ports:
      - "0.0.0.0:80:80"
      - "0.0.0.0:443:443"

volumes:
  production_caddy: {}

How to correctly configure Caddy and mattermost together?


Solution

  • After read the pichouk. I got the answer here

    chat.{$DOMAIN_NAME} {
        proxy / app:8000 {
        websocket
        transparent
        }
    }