我无法将我的旧域名重定向。我提供了完整的 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:
- "80:80" # http
- "443:443" # https
params:
db_default_text_search_config: "pg_catalog.english"
## 将 db_shared_buffers 设置为总内存的最大 25%。
## 将根据检测到的 RAM 由 bootstrap 自动设置,您也可以覆盖
db_shared_buffers: "128MB"
## 可提升排序性能,但会增加每个连接的内存使用量
#db_work_mem: "40MB"
## 此容器应使用哪个 Git 版本?(默认:tests-passed)
#version: tests-passed
env:
LANG: en_US.UTF-8
# DISCOURSE_DEFAULT_LOCALE: en
## 支持的并发 Web 请求数量?取决于内存和 CPU 核心数。
## 将根据检测到的 CPU 由 bootstrap 自动设置,您也可以覆盖
UNICORN_WORKERS: 2
## TODO: 此 Discourse 实例将响应的域名
DISCOURSE_HOSTNAME: old-domain.com
## 如果希望容器以与上述相同的主机名(-h 选项)启动,请取消注释
## (默认值为 "$hostname-$config")
#DOCKER_USE_HOSTNAME: true
## TODO: 初始注册时将设为管理员和开发者的逗号分隔邮箱列表
## 示例:'user1@example.com,user2@example.com'
DISCOURSE_DEVELOPER_EMAILS: 'admin@old-domain.com'
## TODO: 用于验证新账户和发送通知的 SMTP 邮件服务器
DISCOURSE_SMTP_ADDRESS: smtp.sparkpostmail.com
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: SMTP_Injection
DISCOURSE_SMTP_PASSWORD: "xxxxxxxxxxxxxxxxxxxx"
#DISCOURSE_SMTP_ENABLE_START_TLS: true # (可选,默认为 true)
## 如果添加了 Lets Encrypt 模板,请取消注释以下行以获取免费 SSL 证书
LETSENCRYPT_ACCOUNT_EMAIL: tempemail@temp.com
## 此 Discourse 实例的 CDN 地址(配置为拉取)
## 请参阅 https://meta.discourse.org/t/14857 了解详情
#DISCOURSE_CDN_URL: //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
- git clone https://github.com/team-melbourne-rgsoc2015/discourse-adplugin.git
after_web_config:
- replace:
filename: /etc/nginx/nginx.conf
from: /sendfile.+on;/
to: |
server_names_hash_bucket_size 64;
sendfile on;
- file:
path: /etc/nginx/conf.d/discourse_redirect_1.conf
contents: |
server {
listen 80;
server_name old-domain.com;
return 301 $scheme://new-domain.com$request_uri;
}
after_ssl:
- replace:
filename: "/etc/runit/1.d/letsencrypt"
from: /--keylength/
to: "-d old-domain.com -d new-domain.com --keylength"
## 构建后运行的任何自定义命令
run:
- exec: echo "Beginning of custom commands"
## 如果您想为首次注册设置“发件人”邮箱地址,请取消注释并修改:
## 收到首次注册邮件后,请重新注释该行。该行只需运行一次。
#- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
- exec: echo "End of custom commands"
我在成功重新构建后检查了它。它只是加载而没有进行任何重定向。代码有什么问题?
注意:文件 “discourse_redirect_1.conf” 并未预先创建,它应该被创建吗?