目标 URL 是 https://discourse.example.com:9443。
我们在另一台服务器上使用反向代理(nginx),配置如下:
Spoiler
server {
listen 9443 ssl;
listen [::]:9443 ssl;
client_max_body_size 500m;
server_name discourse.example.com;
ssl_certificate /etc/ssl/certs/example.com.pem;
ssl_certificate_key /etc/ssl/private/example.com.key;
location / {
proxy_pass http://10.250.26.133:3080/;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
以及这个 containers/app.yml:
Spoiler
templates:
- "templates/postgres.template.yml"
- "templates/redis.template.yml"
- "templates/web.template.yml"
- "templates/web.ratelimited.template.yml"
# - "templates/web.ssl.template.yml"
# - "templates/web.letsencrypt.ssl.template.yml"
expose:
- "3080:80" # http
- "443:443" # https
params:
db_default_text_search_config: "pg_catalog.english"
db_shared_buffers: "2048MB"
env:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LANGUAGE: en_US.UTF-8
# DISCOURSE_DEFAULT_LOCALE: en
UNICORN_WORKERS: 8
DISCOURSE_HOSTNAME: discourse.example.com
DISCOURSE_PORT: 9443 # <- 这不起作用
#DOCKER_USE_HOSTNAME: true
DISCOURSE_DEVELOPER_EMAILS: 'admin@example.com'
DISCOURSE_SMTP_ADDRESS: smtp.example.com
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: example-username
DISCOURSE_SMTP_PASSWORD: "p@ssw0rd"
DISCOURSE_SMTP_AUTHENTICATION: login
DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
DISCOURSE_SMTP_DOMAIN: example.com
DISCOURSE_NOTIFICATION_EMAIL: discourse@example.com
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
- git clone https://github.com/discourse/discourse-oauth2-basic.git
run:
- exec: echo "Beginning of custom commands"
- exec: echo "End of custom commands"
我运行了 ./launcher rebuild app。
随后,https://discourse.example.com:9443 这个 URL 可以正常工作。
但是:
-
我无法创建管理员用户,因为 Discourse 将我重定向到了不带 9443 端口的 URL。
我不得不通过控制台创建管理员(./launcher enter app,然后运行rake admin:create)。 -
由于同样的原因,我无法注册任何其他用户。
-
我无法通过 Gitea OAuth 连接,因为 Discourse 生成的授权 URL 中的 redirect_uri 不正确(URL 中缺少 9443 端口)。
有没有办法在 DISCOURSE_HOSTNAME 旁边指定 DISCOURSE_PORT?