Traefikに関するDiscourseの解決策

以前にも議論されたことは承知していますが、以前の議論のほとんどは古いバージョンの Discourse と Traefik に関するものだったので、ここで助けを求めています :smiley:

何が機能していますか?
すべての公開ポートをコメントアウトするまで、Discourse は外部からアクセス可能で正常に機能していました。

Traefik も外部からアクセス可能です。

何が機能していませんか?
Discourse にアクセスしようとすると、Bad Gateway エラーが発生しますが、いろいろ試しているうちに 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 -

これで開始します。データ/traefik.yml は こちら から、データ/dynamic_conf.yml は 同じ人物 から取得しました。

これは機能します。

Discourse (/var/discourse/containers/app.yml) の内部では、次のようになっています。

## this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed


templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
#  - "templates/web.ssl.template.yml"
#  - "templates/web.letsencrypt.ssl.template.yml"


## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
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(`***`)      ## Hier eure Domain eintragen
  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(`***`)      ## Hier eure Domain eintragen
  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"

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  #db_shared_buffers: "256MB"

  ## can improve sorting performance, but adds memory usage per-connection
  #db_work_mem: "40MB"

  ## Which Git revision should this container use? (default: 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


  ## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override
  #UNICORN_WORKERS: 3


  ## TODO: The domain name this Discourse instance will respond to
  ## Required. Discourse will not work with a bare IP number.
  DISCOURSE_HOSTNAME: ***


  ## Uncomment if you want the container to be started with the same
  ## hostname (-h option) as specified above (default "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true


  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example 'user1@example.com,user2@example.com'

///leaving email config out for privacy reasons - that worked when directly exposed


  ## The http or https CDN address for this Discourse instance (configured to pull)
  ## see https://meta.discourse.org/t/14857 for details
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com


  ## The maxmind geolocation IP address key for IP address lookup
  ## see https://meta.discourse.org/t/-/137387/23 for details
  DISCOURSE_MAXMIND_LICENSE_KEY: ***


## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log


## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git


## Any custom commands to run after building
run:
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - exec: echo "End of custom commands"

それで…お願いします!

何が間違っていましたか?

それは、コンテナが何らかの形で破損していることを示唆していますが、Traefikがそれに接続するように正常に設定されているため、おそらくTraefikの設定に戻りたいのでしょう。WebサーバーとRailsが起動するまで十分に待たなかった可能性があります。app.ymlに明らかな問題は見られません。

ありがとうございます、@pfaffman

しばらく(11時間待ちましたが、そのコンピューターはそれほど遅くはありません)待ってみましたが、解決しませんでした。

discourse が私のネットワーク「proxy」に接続するように強制できたのでしょうか?確認する方法はありますか?

docker ps は、discourse がポートを使用しなくなったことを示していますが、これは私が望んでいたことです。しかし、discourse が何かに接続しているかどうかはわかりません。

./launcher enter app
wget www.google.de

は、Discourse がインターネットに接続されていることを示しています。しかし、外部からアクセスできません…

ポート3000ではなく、ポート80を試してください

「いいね!」 1

うまくいきました!!! 本当に本当にありがとうございます。1週間も気になっていました。

「いいね!」 1

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.