服务端使用 Docker 版思源进行伺服搭建配置
镜像地址
启动参数:
docker run \
--detach \
--name siyuan \
-v /data/siyuan:/data/siyuan \
-p 6806:6806 \
-u 1000:1000 b3log/siyuan \
--ssl=true \
--lang=zh_CN \
--accessAuthCode=123456 \
--workspace=/data/siyuan/
nginx 反代,需要配置反代 WebSocket,以下配置 HTTPS 和 wss
upstream siyuan {
server 127.0.0.1:6806; # ip + 端口
}
map $http_upgrade $conn_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen 443 ssl;
server_name siyuan.cjzshilong.cn;
access_log /var/log/nginx/siyuan.cjzshilong.cn_access.log log_json;
error_log /var/log/nginx/siyuan.cjzshilong.cn_error.log error;
ssl_certificate /usr/local/nginx/conf/ssl/siyuan.cjzshilong.cn_bundle.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/siyuan.cjzshilong.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://siyuan;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $conn_upgrade;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
http 反向代理配置:
upstream siyuan {
server 127.0.0.1:6806; # ip + 端口
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name siyuan.cjzshilong.cn;
location / {
proxy_pass http://siyuan; #请求转向 siyuan 定义的服务器列表
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
我的博客即将同步至腾讯云开发者社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=2he0nxgqufsw8