Discourse가 일부 로드되고 일부 css, js, svg 파일에서 404 오류 발생

디스코urs 포럼 멤버 여러분께 인사드립니다.

이전에는 이 링크를 사용하여 디스코urs를 성공적으로 설치한 적이 있습니다. 하지만 이번에는 아래 오류가 발생하여 설치를 위해 도움을 요청드립니다.

이 문제를 해결하게 되면, 어떻게 수정했는지 공유하겠습니다.

웹 브라우저를 통해 디스코urs를 설치할 때 다음과 같은 오류가 발생했습니다.

[Error] Failed to load resource: the server responded with a status of 404 () (wizard_c4aee3fa9261fde8baf9c596832d10e16a40c298.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 () (wizard-vendor-e639f7bedb553c62a51539714bacf10a7bb9c2a68ee57d9d9e9da130ede31d8b.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 () (tada.svg, line 0)
[Error] Failed to load resource: the server responded with a status of 404 () (ember_jquery-57d09ec67e9e407d9b0d42aa1fefd1a470c45310d953b07793a3ca8adc6ec599.js, line 0)
[Error] Refused to execute https://forum.sangean.co.kr/assets/ember_jquery-57d09ec67e9e407d9b0d42aa1fefd1a470c45310d953b07793a3ca8adc6ec599.js as script because “X-Content-Type: nosniff” was given and its Content-Type is not a script MIME type.
[Error] Refused to execute https://forum.sangean.co.kr/assets/wizard-vendor-e639f7bedb553c62a51539714bacf10a7bb9c2a68ee57d9d9e9da130ede31d8b.js as script because “X-Content-Type: nosniff” was given and its Content-Type is not a script MIME type.
[Error] Failed to load resource: the server responded with a status of 404 () (tada.svg, line 0)

제 환경은 - Ubuntu 18.94, Nginx 리버스 프록시입니다.

모든 과정을 root 권한으로 설치했기 때문에, /var/discourse/shared/standalone의 “ls -al” 정보를 여기에 첨부합니다.

권한 관련 문제라고 추측하지만, 확신은 하지 못합니다.

drwxr-xr-x 11 root root 4096 Apr 4 05:50 .
drwxr-xr-x 3 root root 4096 Apr 4 04:45 ..
drwxr-xr-x 2 1000 www-data 4096 Apr 4 04:45 backups
drwxr-xr-x 4 root root 4096 Apr 4 04:45 log
drwxr-xr-x 2 uuidd uuidd 4096 Apr 4 04:45 postgres_backup
drwx------ 19 uuidd uuidd 4096 Apr 4 05:50 postgres_data
drwxrwxr-x 3 uuidd uuidd 4096 Apr 4 05:50 postgres_run
drwxr-xr-x 2 landscape ssh 4096 Apr 4 06:00 redis_data
drwxr-xr-x 4 root root 4096 Apr 4 05:50 state
drwxr-xr-x 4 1000 www-data 4096 Apr 4 05:50 tmp
drwxr-xr-x 3 1000 www-data 4096 Apr 4 04:47 uploads

제 /nginx/sites-available/forum.sangean.co.kr 설정 파일입니다.

server {
listen 80; listen [::]:80;
server_name forum.sangean.co.kr;

return 301 https://$host$request_uri;

}

server {
server_name forum.sangean.co.kr www.forum.sangean.co.kr;

access_log /var/log/nginx/forum.sangean.co.kr.access.log ;
error_log /var/log/nginx/forum.sangean.co.kr.error.log;

include common/locations-wo.conf;
include /var/www/forum.sangean.co.kr/conf/nginx/*.conf;

location / {
    proxy_pass http://forum.sangean.co.kr:25654/;
    proxy_set_header Host $http_host;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_redirect http://forum.sangean.co.kr:25654/ https://forum.sangean.co.kr;
}

}

포함된 nginx 설정 파일이나 디스코urs 설정 파일이 필요하시면 이 게시물을 편집하거나 답변으로 공유하겠습니다.

많은 도움 부탁드립니다.

nginx 설정이 올바르지 않아 보입니다. yml 파일도 공유해 주시겠습니까?

25654 포트에서 discourse를 실행하려는 것 같은데, discourse sockets 템플릿을 사용하면 소켓으로 쉽게 실행한 후 프록시를 통해 요청을 소켓으로 전달할 수 있습니다.

아래 가이드를 참고하시면 nginx 설정을 더 잘 이해할 수 있습니다: Add an offline page to display when Discourse is rebuilding or starting up

@itsbhanusharma 답변 주셔서 정말 감사합니다

제 스스로도 해당 게시글을 읽고 적용해 보겠습니다.

제 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 포트를 노출해야 하는가?
## Apache나 nginx와 같은 다른 웹서버와 포트를 공유하려면
## 자세한 내용은 https://meta.discourse.org/t/17247 을 참조하세요
expose:
  - "25654:80"
  #- "80:80"   # http
  #- "443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

## db_shared_buffers를 총 메모리의 최대 25%로 설정하세요.
  ## 감지된 RAM에 따라 bootstrap이 자동으로 설정하거나, 직접 오버라이드할 수 있습니다
  db_shared_buffers: "256MB"

  ## 정렬 성능을 향상시킬 수 있지만, 연결당 메모리 사용량이 증가합니다
  #db_work_mem: "40MB"

  ## 이 컨테이너는 어떤 Git 리비전을 사용해야 하는가? (기본값: tests-passed)
  #version: tests-passed

env:
  LANG: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  ## 동시에 처리할 수 있는 웹 요청은 몇 개인가? 메모리와 CPU 코어 수에 따라 다릅니다.
  ## 감지된 CPU에 따라 bootstrap이 자동으로 설정하거나, 직접 오버라이드할 수 있습니다
  UNICORN_WORKERS: 3

  ## TODO: 이 Discourse 인스턴스가 응답할 도메인 이름
  ## 필수 항목입니다. Discourse는 IP 주소만으로는 작동하지 않습니다.
  DISCOURSE_HOSTNAME: 'forum.sangean.co.kr'

  ## 컨테이너가 위에서 지정한 것과 동일한

## 호스트 이름(-h 옵션)으로 시작되도록 하려면 주석을 해제하세요 (기본값 "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO: 초기 가입 시 관리자 및 개발자로 설정될 쉼표로 구분된 이메일 목록
  ## 예: 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'admin@sangean.co.kr'

  ## TODO: 새 계정을 검증하고 알림을 보내는 데 사용되는 SMTP 메일 서버
  # SMTP 주소, 사용자 이름, 비밀번호는 필수입니다
  # 경고: SMTP 비밀번호의 '#' 문자는 문제를 일으킬 수 있습니다!
  DISCOURSE_SMTP_ADDRESS: smtp.elasticemail.com
  DISCOURSE_SMTP_PORT: 2525
  DISCOURSE_SMTP_USER_NAME: admin@sangean.co.kr
  DISCOURSE_SMTP_PASSWORD: 58BD8932EDB9FEF87F8B3F0A75F482295B4B
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (선택 사항, 기본값 true)

  ## Lets Encrypt 템플릿을 추가했다면 무료 SSL 인증서를 얻으려면 아래 주석을 해제하세요
  #LETSENCRYPT_ACCOUNT_EMAIL: me@example.com

  ## 이 Discourse 인스턴스의 http 또는 https CDN 주소 (추기 위해 설정됨)
  ## 자세한 내용은 https://meta.discourse.org/t/14857 을 참조하세요
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com

## Docker 컨테이너는 상태가 없으며(stateless), 모든 데이터는 /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 "Beginning of custom commands"
  ## 첫 번째 가입 시 'From' 이메일 주소를 설정하려면 주석을 해제하고 변경하세요:
  ## 첫 가입 이메일을 받은 후에는 해당 줄을 다시 주석 처리하세요. 한 번만 실행하면 됩니다.
  - exec: rails r "SiteSetting.notification_email='admin@sangean.co.kr'"
  - exec: echo "End of custom commands"

여기서 제가 제안할 수 있는 것은 제가 제안했던 게시글을 구현하는 것뿐입니다. 그렇게 하면 리버스 프록시 문제로 인한 어려움이 없게 됩니다.