리버스 프록시 설정에서 무한 301 리다이렉트 발생

안녕하세요, Discourse 설치 관련해서 문제가 발생했습니다. 웹사이트에 접속하려고 하면 301 리다이렉트가 무한 반복됩니다.

Discourse 인스턴스에 대한 nginx HOST 설정은 다음과 같습니다.

server
{
        server_name dis.ob**********ie.fr;
        access_log /var/log/nginx/dis_access.log;
        error_log /var/log/nginx/dis_error.log;
        location / {
                proxy_pass http://dis.ob**********ie.fr:8150;
                #http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
                proxy_set_header Host $http_host;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Real-IP $remote_addr;
        }
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/dis.ob**********ie.fr/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/dis.ob**********ie.fr/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server
{
    if ($host = dis.ob**********ie.fr) {
        return 301 https://$host$request_uri;
    } # managed by Certbo

        server_name dis.ob**********ie.fr;
    listen 80;
    return 404; # managed by Certbot
}

app.yml 파일은 다음과 같습니다.

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.socketed.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:
    - "8150:80"   # http

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: "1024MB"

  ## 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: fr_FR.UTF-8
  LANG: fr_FR.UTF-8
  LANGUAGE: fr_FR.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: 4

  ## TODO: The domain name this Discourse instance will respond to
  ## Required. Discourse will not work with a bare IP number.
  DISCOURSE_HOSTNAME: dis.ob**********ie.fr
  ## 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'
  DISCOURSE_DEVELOPER_EMAILS: 'admin@ob**********ie.fr

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ADDRESS: mail.ob**********ie.fr
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: discourse@ob**********ie.fr
  DISCOURSE_SMTP_PASSWORD: "*********************"
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
  DISCOURSE_SMTP_DOMAIN: ob**********ie.fr
  DISCOURSE_NOTIFICATION_EMAIL: noreply@ob**********ie.fr

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  LETSENCRYPT_ACCOUNT_EMAIL: me@example.com

  ## 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: 1234567890123456

## 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"

모두의 도움에 감사드립니다 :heart:

비표준 포트를 사용하는 것은 지원되지 않습니다. 포트 443과 80이 열려 있어야 합니다. 여러 번 재구축을 수행했다면 Let’s Encrypt의 속도 제한(rate limit)에 걸릴 수 있으며, 일주일간 기다리거나 여러 도메인으로 Let’s Encrypt 설정하기에 설명된 대로 두 번째 호스트 이름을 추가해야 합니다.

호스트나 게스트에서 비표준 포트가 지원되지 않는다는 말씀이신가요?
다음 튜토리얼을 따르고 있었습니다:

여기서 이렇게 적혀 있습니다:

웹소켓을 사용할 수 없는 다른 리버스 프록시를 사용하는 경우, 위의 섹션에서 - 8080:80과 같이 다른 포트를 노출할 수 있습니다.

리버스 프록시에 대해 언급하지 않으셨네요. 문제는 discourse가 아니라 리버스 프록시에 있을 가능성이 높습니다. 하지만 SSL과 Let’s Encrypt 템플릿을 제거하고 해당 사항을 리버스 프록시에서 처리해야 할 것 같습니다.

감사합니다. 이제 연결을 시도할 때 502 Bad Gateway 오류가 발생합니다.
로컬의 127.0.0.1:8150으로 연결을 시도했지만 아무 응답도 받지 못했습니다.
새로운 discourse app.yml 파일은 다음과 같습니다:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.socketed.template.yml"
## Lets Encrypt(https)를 추가하려면 아래 두 줄의 주석을 해제하세요
#- "templates/web.ssl.template.yml"
# - "templates/web.letsencrypt.ssl.template.yml"

expose:
    - "8150:80"   # http

params:
  db_default_text_search_config: "pg_catalog.english"
  db_shared_buffers: "1024MB"

env:
  LC_ALL: fr_FR.UTF-8
  LANG: fr_FR.UTF-8
  LANGUAGE: fr_FR.UTF-8
  EMBER_CLI_PROD_ASSETS: 1
  UNICORN_WORKERS: 4
  DISCOURSE_HOSTNAME: dis.ob******ie.fr
  DOCKER_USE_HOSTNAME: true
  DISCOURSE_DEVELOPER_EMAILS: 'admin@ob******ie.fr'
  DISCOURSE_SMTP_ADDRESS: mail.ob******ie.fr
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: discourse@ob******ie.fr
  DISCOURSE_SMTP_PASSWORD: "Safe Password"
  DISCOURSE_SMTP_DOMAIN: ob******ie.fr
  DISCOURSE_NOTIFICATION_EMAIL: noreply@ob******ie.fr
  LETSENCRYPT_ACCOUNT_EMAIL: me@example.com
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

run:
  - exec: echo "Beginning of custom commands"
  - exec: echo "End of custom commands"
        cd: $home/plugins

좋아요, 찾았어요! Nginx 게스트가 소켓을 리스닝하고 있었고, 호스트도 같은 소켓을 사용하도록 설정했거든요. 정말 감사합니다!