Nginx에서 502 게이트웨이 오류가 발생하면?

해결됨: nginx 서버를 비활성화하고, discourse-setup을 실행한 후, nginx 서버를 다시 활성화하고 앱을 재빌드했습니다.

안녕하세요. 이 가이드에 따라 Discourse를 설치하려고 하고 있습니다.

다음은 제가 편집한 app.yml 파일입니다 (discourse 폴더에서 복사하여 가이드에 따라 편집함):

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"

## 이 컨테이너가 어떤 TCP/IP 포트를 노출해야 하나요?
## Discourse가 Apache나 nginx 같은 다른 웹서버와 포트를 공유하려면,
## 자세한 내용은 https://meta.discourse.org/t/17247 를 참조하세요
expose:
#  - "80:80"   # http
#  - "2222:22"
#  - "443:443" # https

제 discourse.conf nginx 블록은 다음과 같습니다:
server {

server_name forum.myhost;  #
listen [::]:443 ssl http2 ipv6only=on; # Certbot에 의해 관리됨
listen 443 ssl http2; # Certbot에 의해 관리됨
ssl_certificate /etc/letsencrypt/live/forum.myhost/fullchain.pem; # Certbot에 의해 관리됨
ssl_certificate_key /etc/letsencrypt/live/forum.myhost/privkey.pem; # Certbot에 의해 관리됨
include /etc/letsencrypt/options-ssl-nginx.conf; # Certbot에 의해 관리됨
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # Certbot에 의해 관리됨
ssl on;
http2_idle_timeout 5m; # 기본값 3m에서 증가;

location / {
    proxy_pass 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 https;
    proxy_set_header X-Real-IP $remote_addr;
}
}
server {
if ($host = forum.myhost) {
    return 301 https://$host$request_uri;
} # Certbot에 의해 관리됨

server_name www.forum.myhost;
return 301 $scheme://forum.myhost$request_uri;

    listen 80;
    listen [::]:80;

    server_name forum.myhost;
return 404; # Certbot에 의해 관리됨
}

서버는 SSL(Certbot 설치됨)로 작동하며, 주 도메인에서는 http를 https로 리디렉션하지만 포럼 도메인에서는 502 Gateway 오류가 표시됩니다. Cloudflare(성능 또는 보안 옵션 활성화 없이)를 사용하고 있습니다.

어떤 도움이든 감사하겠습니다. 이 문제를 해결하기 위한 정보를 위해 "Google: “open ports YOUR CLOUD SERVICE”"라고 표시되므로 discourse-setup을 실행할 수 없습니다.

방화벽도 확인했습니다.

수정: 이 줄에 문제가 있는 것일까요? (이 파일을 폴더에서 찾을 수 없습니다)
proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;

왜 nginx를 프록시로 사용하나요?

이 서버에 다른 웹사이트가 있나요?

네, Stephen. 저는 nginx를 사용 중이며 Drupal 사이트를 업로드할 계획입니다. 제가 댓글로 언급했듯이 기본 도메인은 SSL로 정상 작동하고 있고, 포럼 서브도메인은 502 게이트웨이 오류를 표시합니다.

그래서 서버에서 nginx를 중지했는데, 이제 discourse-setup은 작동하지만 다음과 같은 오류 메시지가 표시됩니다:

Enabling Let’s Encrypt
web.ssl.template.yml NOT ENABLED–was it on already?
letsencrypt.ssl.template.yml NOT ENABLED – was it on already?

Unfortunately, there was an error changing

-d This may happen if you have made unexpected changes.

서버에 Let’s Encrypt가 설치되어 있는 상황에서 Discourse에서 Let’s Encrypt를 사용해야 하는지, 아니면 외부에서 사용해야 하는지 정말로 잘 모르겠습니다.

읽어주셔서 감사합니다.

마지막 수정: 방금 서버의 nginx를 다시 시작했는데, 1차 및 2차 도메인 모두 정상 작동합니다 (Discourse 인스턴스의 Certbot 기반 서버 Let’s Encrypt를 유지하면서).