搭建 solo 博客

本贴最后更新于 801 天前,其中的信息可能已经天翻地覆

1.安装 docker

2.安装 mysql

3.安装 nginx

./configure --prefix=/root/nginx --with-http_addition_module --with-http_flv_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-http_v2_module

4.docker 安装 solo

docker run --detach --name solo --network=host \
    --env RUNTIME_DB="MYSQL" \
    --env JDBC_USERNAME="******" \
    --env JDBC_PASSWORD="******" \
    --env JDBC_DRIVER="com.mysql.cj.jdbc.Driver" \
    --env JDBC_URL="jdbc:mysql://1.1.1.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true" \
    b3log/solo --listen_port=8080 --server_scheme=https --server_host=oldbaiyang.com --server_port=

5.申请 https 证书

acme.sh --issue -d oldbaiyang.com --nginx /root/nginx/conf/oldbaiyang.com.conf
acme.sh --install-cert -d oldbaiyang.com \
--key-file       /root/nginx/ssl/oldbaiyang.com/oldbaiyang.com.key  \
--fullchain-file  /root/nginx/ssl/oldbaiyang.com/fullchain.cer \
--reloadcmd     "nginx -s reload"

6.nginx 配置

upstream backend {
    server localhost:8080; # Solo 监听端口
}

server {
    listen       80;
    server_name  oldbaiyang.com; # 博客域名

    access_log off;
    return 301 https://$server_name$request_uri;

}

server {
    listen       443 ssl http2;
    listen       [::]:443 ssl http2;
    server_name  oldbaiyang.com;
    charset utf8;

    ssl_certificate "/root/nginx/ssl/oldbaiyang.com/fullchain.cer";
    ssl_certificate_key "/root/nginx/ssl/oldbaiyang.com/oldbaiyang.com.key";
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    # 重要! 原有的接口代理可以不用修改,在内部使用http
    location / {
        proxy_pass http://backend$request_uri;
        proxy_set_header  Host $host;
        proxy_set_header  X-Real-IP  $remote_addr;
        client_max_body_size  10m;
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...
  • h4n17

    太感谢了,折腾了几个小时 nginx 反向代理,最后参考你的配置文件,终于成功了 ❤️ ❤️

    ❤️