通过Caddy确保最重要的连接,但websocket无法正常工作

时间:2019-02-04 10:01:26

标签: docker https websocket caddy mattermost

我正在尝试通过mattermost保护我的Caddy连接。最接近的一个来自micheljung answer

  

配置网络和应用的方式没有意义。现在可以了。   我做了什么:

     

启用“让我们加密并将端口80转换为443”
  让应用公开   端口80和443(在Dockerfile和docker-compose.yml中配置)
  删除Web容器,因为它的唯一目的基本上是SSL,   现在由Mattermost处理
  利润!

我确实听了他的回答。但无法使用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

1 个答案:

答案 0 :(得分:0)

看完照片之后。我得到了答案here

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