发布时间:2023-07-31 08:00
https://blog.csdn.net/m0_56069948/article/details/122285951
https://blog.csdn.net/m0_56069948/article/details/122285941
yum install docker-ce-17.12.1.ce
curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# 设置 docker-compose 执行权限
chmod +x /usr/local/bin/docker-compose
.
├── compose-nginx.yml
├── compose-solo-mysql.yml # 这里我是自建的数据,之前有,就没有执行这个编排文件
├── docker-compose.yml
├── nginx
│ ├── cert # https使用
│ │ ├── 7620436_www.example.com.key
│ │ ├── 7620436_www.example.com.pem
│ ├── conf
│ │ └── app.conf
│ └── logs
│ ├── access.log
│ └── error.log
├── solo
│ └── skins # 博客皮肤,可以从官方仓库克隆项目,复制里面的skins
温馨提示:下面的配置请根据这个目录结构对号入座,本人主站也是使用该配置部署。有问题请评论区联系我。
version: \"3\"
services:
solo:
container\\_name: solo
image: b3log/solo
restart: always
environment:
RUNTIME\\_DB: \"MYSQL\"
JDBC\\_USERNAME: \"root\"
JDBC\\_PASSWORD: \"123456\"
JDBC\\_DRIVER: \"com.mysql.cj.jdbc.Driver\"
JDBC\\_URL: \"jdbc:mysql://172.16.96.61:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true\"
command: --listen\\_port=8080 --server\\_scheme=https --server\\_host=www.example.com --lute\\_http=http://172.16.96.61:8249 --server\\_port= --static\\_server\\_scheme=https --static\\_server\\_host=cdn.jsdelivr.net --static\\_path=/gh/88250/solo/src/main/resources
volumes:
# Pay attention to synchronization time
# echo \'Asia/Shanghai\' > /etc/timezone/timezone
- /etc/timezone/timezone:/etc/timezone
- /etc/localtime:/etc/localtime
- ./solo/skins/:/opt/solo/skins/:ro
ports:
- 8080:8080
dns:
- 114.114.114.114
- 8.8.8.8
lute:
image: b3log/lute-http
container\\_name: lute
restart: always
volumes:
# Pay attention to synchronization time
# echo \'Asia/Shanghai\' > /etc/timezone/timezone
- /etc/timezone/timezone:/etc/timezone
- /etc/localtime:/etc/localtime
ports:
- 8249:8249
version: \"3\"
services:
blog-mysql:
image: mysql:8.0.22
restart: always
container\\_name: blog-mysql
privileged: false
ports:
- 3306:3306
networks:
- blog-extranet
environment:
- MYSQL\\_ROOT\\_PASSWORD=123456
volumes:
- /etc/localtime:/etc/localtime:ro
- ./mysql/conf/:/etc/mysql/
- ./mysql/data/:/var/lib/mysql/
- ./mysql/init/:/docker-entrypoint-initdb.d/
- ./mysql/logs/:/logs/
networks:
blog-extranet:
driver: bridge
version: \"3\"
services:
nginx:
image: nginx:1.14
restart: always
container\\_name: nginx
privileged: true
ports:
- 80:80
- 443:443
volumes:
- /etc/localtime:/etc/localtime:ro
- ./nginx/conf/:/etc/nginx/conf.d/
- ./nginx/cert/:/etc/nginx/cert/
- ./nginx/logs/:/etc/nginx/log/
dns:
- 114.114.114.114
- 8.8.8.8
networks:
blog-extranet:
driver: bridge
upstream blog {
# server www.example.com:8080;
# Solo 监听端口,这里的ip最好是你的云服务器内网ip,可以通过ip addr 或者ifconfig查看
server 172.16.96.61:8080;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name www.example.com;
# http 重定向到https 配置
if ($http_x_forwarded_proto = \"http\") {
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl;
server_name www.example.com;
charset utf-8;
access_log /etc/nginx/log/access.log;
error_log /etc/nginx/log/error.log;
ssl_certificate /etc/nginx/cert/7620436_www.example.com.pem;
ssl_certificate_key /etc/nginx/cert/7620436_www.example.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://blog$request_uri;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
}
# 防止爬虫抓取
if ($http_user_agent ~* \"360Spider|JikeSpider|Spider|spider|bot|Bot|2345Explorer|curl|wget|webZIP|qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot|NSPlayer|bingbot\")
{
return 403;
}
error_page 403 404 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html/error-page;
}
}
B3log开源博客搭建
docker 安装
docker-compose 安装
注意
项目结构
docker-compose.yml
compose-solo-mysql.yml
compose-nginx.yml
app.conf (nginx配置)
__EOF__
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NVfi5zlW-1650170655545)(https://blog.csdn.net/jockming)]itwetouch - 本文链接: https://blog.csdn.net/jockming/p/16155249.html