返回

Docker部署思源笔记

docker-compose.yml 文件配置

替换说明:

  • /var/www/siyuan/ 替换为你的实际物理路径。
  • Password 替换为你的访问密码。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
version: "3.9"
services:
  siyuan:
    image: b3log/siyuan
    container_name: siyuan
    restart: always
    ports:
      - 6806:6806
    volumes:
      - ./:/siyuan/workspace
    command:
      - "--workspace=/siyuan/workspace/"
      - "--lang=zh_CN"
      - "--accessAuthCode=<password>"

反向代理配置

替换说明:

  • your_domain.com 替换为你自己的域名。
  • path 替换为你的SSL证书的实际路径。
 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
upstream siyuan {
    server 127.0.0.1:6806;  # 将流量定向到本地的6806端口
}

server {
    listen 80;
    listen [::]:80;
    server_name your_domain.com;  # 设置服务器域名

    # 将所有 HTTP 请求重定向到 HTTPS
    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name your_domain.com;  # 设置服务器域名

    # 配置 SSL 证书路径
    ssl_certificate path/fullchain.cer;
    ssl_certificate_key path/file.key;

    client_max_body_size 0;  # 不限制请求体大小

    location / {
        proxy_pass http://siyuan;  # 反向代理到上游 siyuan
        proxy_set_header HOST $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /ws {
        proxy_pass http://siyuan;
        proxy_read_timeout 60s;  # 设置读取超时时间
        proxy_http_version 1.1;  # 使用 HTTP 1.1
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'Upgrade';  # 支持 WebSocket
    }
}
使用 Hugo 构建
主题 StackJimmy 设计