honggian
(honggian)
1
大家好,Discourse 论坛的会员们。
我之前按照这个 链接 成功安装过 Discourse,但这次遇到了以下错误,需要大家帮忙解决安装问题。
解决此问题后,我会分享我是如何修复它的。
通过网页浏览器安装 Discourse 时,我遇到了以下错误:
[错误] 资源加载失败:服务器响应状态为 404 () (wizard_c4aee3fa9261fde8baf9c596832d10e16a40c298.css,第 0 行)
[错误] 资源加载失败:服务器响应状态为 404 () (wizard-vendor-e639f7bedb553c62a51539714bacf10a7bb9c2a68ee57d9d9e9da130ede31d8b.js,第 0 行)
[错误] 资源加载失败:服务器响应状态为 404 () (tada.svg,第 0 行)
[错误] 资源加载失败:服务器响应状态为 404 () (ember_jquery-57d09ec67e9e407d9b0d42aa1fefd1a470c45310d953b07793a3ca8adc6ec599.js,第 0 行)
[错误] 拒绝执行 https://forum.sangean.co.kr/assets/ember_jquery-57d09ec67e9e407d9b0d42aa1fefd1a470c45310d953b07793a3ca8adc6ec599.js 脚本,因为设置了 “X-Content-Type: nosniff”,且其 Content-Type 不是脚本 MIME 类型。
[错误] 拒绝执行 https://forum.sangean.co.kr/assets/wizard-vendor-e639f7bedb553c62a51539714bacf10a7bb9c2a68ee57d9d9e9da130ede31d8b.js 脚本,因为设置了 “X-Content-Type: nosniff”,且其 Content-Type 不是脚本 MIME 类型。
[错误] 资源加载失败:服务器响应状态为 404 () (tada.svg,第 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 配置文件或 Discourse 配置文件,我可以编辑或回复此帖子提供更多信息。
非常感谢大家!
您的 nginx 配置看起来不太对。您能分享一下您的 yml 文件吗?
我猜您试图在 25654 端口运行 Discourse,但其实您可以轻松使用 Discourse 的 sockets 模板,将其运行在 socket 上,并通过代理将请求转发到该 socket。
您可以参考以下指南更好地理解 nginx 配置:Add an offline page to display when Discourse is rebuilding or starting up
honggian
(honggian)
3
@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 端口?
## 如果您希望 Discourse 与另一个 Web 服务器(如 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%。
## 将由 bootstrap 根据检测到的 RAM 自动设置,您也可以覆盖
db_shared_buffers: "256MB"
## 可以改善排序性能,但会增加每个连接的内存使用量
#db_work_mem: "40MB"
## 此容器应使用哪个 Git 修订版?(默认:tests-passed)
#version: tests-passed
env:
LANG: en_US.UTF-8
# DISCOURSE_DEFAULT_LOCALE: en
## 支持多少并发 Web 请求?取决于内存和 CPU 核心数。
## 将由 bootstrap 根据检测到的 CPU 自动设置,您也可以覆盖
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 容器是无状态的;所有数据都存储在 /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='admin@sangean.co.kr'"
- exec: echo "结束自定义命令"
我唯一能建议的是实施我之前提到的帖子……这样,你就不会遇到反向代理的问题了。
1 个赞