暗黑模式
Discourse
相关链接
Self-Hosting
准备域名
类型 | 主机记录 | 记录值 |
---|---|---|
A | bbs.example.com | 22.33.44.55 |
准备管理员邮箱
添加域名

类型 | 主机记录 | 记录值 |
---|---|---|
TXT | @ | brevo-code:32061c704ef958c299ac3e4c1e306d72 |
CNAME | brevo1._domainkey | b1.example-com.dkim.brevo.com |
CNAME | brevo2._domainkey | b2.example-com.dkim.brevo.com |
TXT | _dmarc | v=DMARC1; p=none; rua=mailto:rua@dmarc.brevo.com |
添加 Sender

查看 SMTP Keys

开始部署
INFO
准备以下环境:
- 一台 Ubuntu 服务器
- The default of 1 GB RAM works fine for small Discourse communities. We recommend 2 GB RAM for larger communities.
- 安装
docker
docker compose
- 安装
git
拉取代码
bash
ssh ubuntu@your-host
sudo -s # 切换至 root
git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse
chmod 700 containers
1
2
3
4
5
2
3
4
5
初始化配置
选择以下方式之一:
- 我的服务器的
80/443
端口没有被占用:- 执行:
./discourse-setup
- 此命令会生成
/var/discourse/containers/app.yml
配置文件,并监听80/443
端口
- 执行:
- 我的服务器
80/443
被占用了,或者我要在服务器上部署多个应用,例如用caddy/nginx
反向代理多个应用:推荐配置
yml## this is the all-in-one, standalone Discourse Docker container template ## ## After making changes to this file, you MUST rebuild ## /var/discourse/launcher rebuild app ## ## BE *VERY* CAREFUL WHEN EDITING! ## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT! ## visit http://www.yamllint.com/ to validate this file as needed templates: - "templates/postgres.template.yml" - "templates/redis.template.yml" - "templates/web.template.yml" ## Uncomment the next line to enable the IPv6 listener #- "templates/web.ipv6.template.yml" - "templates/web.ratelimited.template.yml" ## Uncomment these two lines if you wish to add Lets Encrypt (https) #- "templates/web.ssl.template.yml" # 不使用,因为我们用自己的 caddy #- "templates/web.letsencrypt.ssl.template.yml" # 不使用,因为我们用自己的 caddy ## which TCP/IP ports should this container expose? ## If you want Discourse to share a port with another webserver like Apache or nginx, ## see https://meta.discourse.org/t/17247 for details expose: - "8180:80" # 80 端口留给 caddy # - "443:443" # https params: db_default_text_search_config: "pg_catalog.chinese" ## Set db_shared_buffers to a max of 25% of the total memory. ## will be set automatically by bootstrap based on detected RAM, or you can override db_shared_buffers: "2048MB" ## can improve sorting performance, but adds memory usage per-connection #db_work_mem: "40MB" ## Which Git revision should this container use? (default: tests-passed) #version: tests-passed env: LC_ALL: zh_CN.UTF-8 LANG: zh_CN.UTF-8 LANGUAGE: zh_CN.UTF-8 DISCOURSE_DEFAULT_LOCALE: zh_CN ## How many concurrent web requests are supported? Depends on memory and CPU cores. ## will be set automatically by bootstrap based on detected CPUs, or you can override UNICORN_WORKERS: 8 # number of CPUs ## TODO: The domain name this Discourse instance will respond to ## Required. Discourse will not work with a bare IP number. DISCOURSE_HOSTNAME: 'bbs.example.com' # 注意:换成真实的 DISCOURSE_FORCE_HTTPS: true ## Uncomment if you want the container to be started with the same ## hostname (-h option) as specified above (default "$hostname-$config") #DOCKER_USE_HOSTNAME: true ## TODO: List of comma delimited emails that will be made admin and developer ## on initial signup example 'user1@example.com,user2@example.com' DISCOURSE_DEVELOPER_EMAILS: 'xxx@outlook.com' # 注意:换成真实的 ## TODO: The SMTP mail server used to validate new accounts and send notifications # SMTP ADDRESS, username, and password are required # WARNING the char '#' in SMTP password can cause problems! DISCOURSE_SMTP_ADDRESS: smtp-relay.brevo.com DISCOURSE_SMTP_PORT: 587 # brevo 是 587 端口, qq 邮箱是 465 DISCOURSE_SMTP_USER_NAME: xxxx@smtp-brevo.com # 注意:换成真实的 DISCOURSE_SMTP_PASSWORD: xxxx # 注意:换成真实的 # DISCOURSE_SMTP_FORCE_TLS: false # 如果是587:删除此项,如果是465:true # DISCOURSE_SMTP_ENABLE_START_TLS: true # 如果是587:true(默认),如果是465:false # DISCOURSE_SMTP_DOMAIN: your-sender.com # 可省略,默认为 DISCOURSE_NOTIFICATION_EMAIL 的域名 DISCOURSE_NOTIFICATION_EMAIL: bbs@your-sender.com # brevo sender ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate #LETSENCRYPT_ACCOUNT_EMAIL: me@example.com ## The http or https CDN address for this Discourse instance (configured to pull) ## see https://meta.discourse.org/t/14857 for details #DISCOURSE_CDN_URL: https://discourse-cdn.example.com ## The maxmind geolocation IP account ID and license key for IP address lookups ## see https://meta.discourse.org/t/-/173941 for details #DISCOURSE_MAXMIND_ACCOUNT_ID: 123456 #DISCOURSE_MAXMIND_LICENSE_KEY: 1234567890123456 ## The Docker container is stateless; all data is stored in /shared volumes: - volume: host: /var/discourse/shared/standalone guest: /shared - volume: host: /var/discourse/shared/standalone/log/var-log guest: /var/log ## Plugins go here ## see https://meta.discourse.org/t/19157 for details hooks: after_code: - exec: cd: $home/plugins cmd: - git clone https://github.com/discourse/docker_manager.git ## Any custom commands to run after building run: - exec: echo "Beginning of custom commands" ## If you want to set the 'From' email address for your first registration, uncomment and change: ## After getting the first signup email, re-comment the line. It only needs to run once. #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'" - exec: echo "End of custom commands"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112- 复制以上配置到
/var/discourse/containers/app.yml
- 执行:
/var/discourse/launcher rebuild app
INFO
./launcher destroy app && ./launcher start app
执行快速- 只更新了 SMTP 相关配置时
./launcher rebuild app
执行缓慢
站点配置
- 禁止注册,通过邀请注册
- 审批所有发帖
- Approve unless allowed groups
- Approve new topics unless allowed groups
- 私人聊天
- Personal message enabled groups