通过 Caddy 确保最重要的连接,但 websocket 不起作用

Secure mattermost connection by Caddy but websocket is not work

我正在尝试通过 Caddy 保护我的 mattermost 连接。最接近的来自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!

我确实跟着他的回答。但无法使用 websocket 功能 这是我试过的

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: {}

如何正确配置Caddymattermost一起?

看完比丘克。我得到了答案here

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