我知道这之前已经讨论过,但大多数旧的讨论都涉及旧版本的 discourse 和 traefik - 所以我在这里需要帮助 ![]()
什么有效?
在注释掉所有暴露的端口之前,Discourse 可以从外部访问并且运行正常。
Traefik 也可以从外部访问。
什么无效?
尝试访问 Discourse 时出现“网关错误”,但在尝试我读到的不同内容时,我也遇到了 404。
我的 traefik 设置:
cat docker-compose.yml
version: '3'
services:
traefik:
image: traefik:latest
# network_mode: "host"
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
ports:
- 80:80
- 443:443
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data/traefik.yml:/traefik.yml:ro
- ./data/acme.json:/acme.json
- ./data/dynamic_conf.yml:/dynamic_conf.yml
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`mydyndns-url`)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=redacted:***"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`mydyndns-url`)"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=http"
- "traefik.http.routers.traefik-secure.service=api@internal"
- "providers.file.filename=/dynamic_conf.yml"
- "traefik.http.routers.traefik-secure.middlewares=secHeaders@file,traefik-auth"
networks:
proxy:
external: true
我使用
docker network create proxy
docker-compose -f /opt/containers/traefik/docker-compose.yml up -d
来启动东西。我使用了来自 这里 的 data/traefik.yml 和来自 同一个人 的 data/dynamic_conf.yml
这有效。
在我的 discourse (/var/discourse/containers/app.yml) 中,我有这个:
## 这是独立的一体化 Discourse Docker 容器模板
##
## 更改此文件后,您必须重建
## /var/discourse/launcher rebuild app
##
## 编辑时请务必*非常*小心!
## YAML 文件对空格或对齐的错误非常非常敏感!
## 如有需要,请访问 http://www.yamllint.com/ 进行验证
templates:
- "templates/postgres.template.yml"
- "templates/redis.template.yml"
- "templates/web.template.yml"
- "templates/web.ratelimited.template.yml"
## 如果您希望添加 Lets Encrypt (https),请取消注释这两行
# - "templates/web.ssl.template.yml"
# - "templates/web.letsencrypt.ssl.template.yml"
## 此容器应暴露哪些 TCP/IP 端口?
## 如果您希望 Discourse 与 Apache 或 nginx 等其他 Web 服务器共享端口,
## 请参阅 https://meta.discourse.org/t/17247 获取详细信息
expose:
# - "7890:80" # http
# - "7891:443" # https
labels:
app_name: discourse
traefik.enable: true
traefik.http.routers.discourse.entrypoints: http
traefik.http.routers.discourse.rule: Host(`***`) ## 在此处输入您的域名
traefik.http.middlewares.discourse-https-redirect.redirectscheme.scheme: https
traefik.http.routers.discourse.middlewares: discourse-https-redirect
traefik.http.routers.discourse-secure.entrypoints: https
traefik.http.routers.discourse-secure.rule: Host(`***`) ## 在此处输入您的域名
traefik.http.routers.discourse-secure.tls: true
traefik.http.routers.discourse-secure.tls.certresolver: http
traefik.http.routers.discourse-secure.service: discourse
traefik.http.services.discourse.loadbalancer.server.port: 3000
traefik.docker.network: proxy
docker_args:
- "--network=proxy"
networks:
- proxy
# - default
params:
db_default_text_search_config: "pg_catalog.english"
## 将 db_shared_buffers 设置为总内存的最多 25%。
## 将由 bootstrap 根据检测到的 RAM 自动设置,或者您可以覆盖它
#db_shared_buffers: "256MB"
## 可以提高排序性能,但会增加每个连接的内存使用量
#db_work_mem: "40MB"
## 此容器应使用哪个 Git 版本? (默认值:tests-passed)
#version: tests-passed
env:
LC_ALL: de_DE.UTF-8
LANG: de_DE.UTF-8
LANGUAGE: dn_DE.UTF-8
EMBER_CLI_PROD_ASSETS: 1
# DISCOURSE_DEFAULT_LOCALE: en
## 此容器支持多少并发 Web 请求?取决于内存和 CPU 核心。
## 将由 bootstrap 根据检测到的 CPU 自动设置,或者您可以覆盖它
#UNICORN_WORKERS: 3
## TODO:此 Discourse 实例将响应的域名
## 必需。Discourse 无法使用裸 IP 地址运行。
DISCOURSE_HOSTNAME: ***
## 如果您希望容器使用与上面指定的相同主机名(-h 选项)启动(默认“$hostname-$config”),请取消注释
#DOCKER_USE_HOSTNAME: true
## TODO:将成为初始注册时管理员和开发人员的逗号分隔电子邮件列表
## 示例“user1@example.com,user2@example.com”
///为保护隐私,省略了电子邮件配置 - 直接暴露时有效
## 此 Discourse 实例的 http 或 https CDN 地址(配置为拉取)
## 请参阅 https://meta.discourse.org/t/14857 获取详细信息
#DISCOURSE_CDN_URL: https://discourse-cdn.example.com
## 用于 IP 地址查找的 maxmind 地理位置 IP 地址密钥
## 请参阅 https://meta.discourse.org/t/-/137387/23 获取详细信息
DISCOURSE_MAXMIND_LICENSE_KEY: ***
## Docker 容器是无状态的;所有数据都存储在 /shared 中
volumes:
- volume:
host: /var/discourse/shared/standalone
guest: /shared
- volume:
host: /var/discourse/shared/standalone/log/var-log
guest: /var/log
## 插件在此处
## 请参阅 https://meta.discourse.org/t/19157 获取详细信息
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- git clone https://github.com/discourse/docker_manager.git
## 构建后要运行的任何自定义命令
run:
- exec: echo "开始自定义命令"
## 如果您想设置首次注册的“发件人”电子邮件地址,请取消注释并更改:
## 获取第一个注册电子邮件后,重新注释该行。它只需要运行一次。
#- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
- exec: echo "结束自定义命令"
所以……拜托!
我做错了什么?