|
1 | 1 | --- |
2 | | -title: 'Nginx域名配置' |
3 | | -sidebar_position: 7 |
| 2 | +title: '域名及SSL证书配置' |
| 3 | +sidebar_position: 8 |
4 | 4 | --- |
5 | 5 |
|
6 | 6 |
|
7 | 7 |
|
8 | | -# Nginx域名配置 |
| 8 | +# 域名及SSL证书配置 |
9 | 9 |
|
10 | 10 | ## 1. 前置条件 🛠️ |
11 | 11 |
|
12 | 12 | - **open-im-server** 和 **chat** 成功启动。 |
13 | 13 | - **Nginx** 已成功安装,包括 SSL 模块。 |
14 | | -- 成功申请两个域名及其 SSL 证书,例如:`web.xx.xx` (用于 IM 服务端及 Web 端), `admin.xx.xx`(用于管理后台)。 |
| 14 | +- 成功申请两个域名及其 SSL 证书,例如:`web.your_domain.com` (用于 IM 服务端及 Web 端), `admin.your_domain.com`(用于管理后台)。 |
15 | 15 | - 开放 443 和 80 端口。 |
16 | 16 |
|
17 | 17 | ## 2. 域名配置模板 📝 |
@@ -57,9 +57,9 @@ server { |
57 | 57 | server_name web.xx.xx; #Your domain name |
58 | 58 | ssl on; |
59 | 59 | #Path of pem file for ssl certificate |
60 | | - ssl_certificate /usr/local/nginx/conf/ssh/web.xx.xx_bundle.pem; |
| 60 | + ssl_certificate /usr/local/nginx/conf/ssh/web.your_domain.com_bundle.pem; |
61 | 61 | #Key file path of ssl certificate |
62 | | - ssl_certificate_key /usr/local/nginx/conf/ssh/web.xx.xx.key; |
| 62 | + ssl_certificate_key /usr/local/nginx/conf/ssh/web.your_domain.com.key; |
63 | 63 |
|
64 | 64 | gzip on; |
65 | 65 | gzip_min_length 1k; |
@@ -125,12 +125,12 @@ server { |
125 | 125 | #Take the domain name "admin.xx.xx" for example |
126 | 126 | server { |
127 | 127 | listen 443; #listening port |
128 | | - server_name admin.xx.xx; #Your domain server_name |
| 128 | + server_name admin.your_domain.com; #Your domain server_name |
129 | 129 | ssl on; |
130 | 130 | #Path of pem file for ssl certificate |
131 | | - ssl_certificate /usr/local/nginx/conf/ssh/admin.xx.xx_bundle.pem; |
| 131 | + ssl_certificate /usr/local/nginx/conf/ssh/admin.your_domain.com_bundle.pem; |
132 | 132 | #Key file path of ssl certificate |
133 | | - ssl_certificate_key /usr/local/nginx/conf/ssh/admin.xx.xx.key; |
| 133 | + ssl_certificate_key /usr/local/nginx/conf/ssh/admin.your_domain.com.key; |
134 | 134 |
|
135 | 135 |
|
136 | 136 | gzip on; |
@@ -194,22 +194,29 @@ server { |
194 | 194 | #Redirection from HTTP to HTTPS redirection |
195 | 195 | server { |
196 | 196 | listen 80; |
197 | | - server_name web.xx.xx; |
| 197 | + server_name web.your_domain.com; |
198 | 198 | rewrite ^(.*)$ https://$host$1 permanent; |
199 | 199 | } |
200 | 200 | ``` |
201 | 201 |
|
202 | 202 | ## 3. Minio 配置 🗄️ |
203 | | - |
204 | | -- **源码部署**: 修改 `config/minio.yml` 文件中的 `externalAddress` 为 `"https://web.xx.xx/im-minio-api"`. |
205 | | -- **Docker 部署**: 修改 `.env` 文件中的 `MINIO_EXTERNAL_ADDRESS` 为 `"https://web.xx.xx/im-minio-api"`. |
| 203 | +- **源码部署**: 修改 `config/minio.yml` 文件中的 `externalAddress` 为 `"https://web.your_domain.com/im-minio-api"`. |
| 204 | +- **Docker 部署**: 修改 `.env` 文件中的 `MINIO_EXTERNAL_ADDRESS` 为 `"https://web.your_domain.com/im-minio-api"`. |
206 | 205 |
|
207 | 206 | ## 4. 启动 Nginx 🚀 |
208 | 207 |
|
209 | 208 | 执行命令 `nginx -s reload` 以重载 Nginx 配置,启用新的域名设置。 |
210 | 209 |
|
211 | 210 | ## 5. 登录验证 🔍 |
212 | 211 |
|
213 | | -- 访问IM web端:`web.xx.xx` |
214 | | -- 访问管理后台:`admin.xx.xx` |
| 212 | +- 访问IM web端:`web.your_domain.com` |
| 213 | +- 访问管理后台:`admin.your_domain.com` |
| 214 | + |
| 215 | +## 6. 修改客户端 SDK 初始化参数 |
| 216 | +在客户端 SDK 中,配置初始化参数如下: |
| 217 | + |
| 218 | +- `apiAddr`: `https://your_domain.com/api` |
| 219 | +- `wsAddr`: `wss://your_domain.com/msg_gateway` |
| 220 | + |
| 221 | + |
215 | 222 |
|
0 commit comments