本文最后更新于 149 天前,如有失效请评论区留言。
本来想自己host个图床的,装好之后发现体验不佳,最后放弃了,anyway记录下步骤给有需要的做个参考吧。
提前准备的
- 已经跑起来的Docker + Nginx
- 图床域名(例子:img.thatwei.com)
Chevereto
把下面的docker-compose.yml和.env_chevereto放在同一个文件夹里,然后”docker compose up -d”启动。
要注意这两个地方:
1. “chevereto” container多用了一个”thatweicom_app-network” network, 这个network必须要nginx container的network一致
2. “chevereto” container 例子里用了“expose”,没法通过ip+port来访问chevereto,需要的话自行改成“ports”。
1. “chevereto” container多用了一个”thatweicom_app-network” network, 这个network必须要nginx container的network一致
2. “chevereto” container 例子里用了“expose”,没法通过ip+port来访问chevereto,需要的话自行改成“ports”。
docker-compose.yml
services:
chevereto_mariadb:
image: mariadb:lts
networks:
- chevereto
volumes:
- db_chevereto:/var/lib/mysql
restart: always
env_file: .env_chevereto
healthcheck:
test: ["CMD", "healthcheck.sh", "--su-mysql", "--connect"]
interval: 10s
timeout: 5s
retries: 3
chevereto:
image: chevereto/chevereto:latest
networks:
- chevereto
- thatweicom_app-network
volumes:
- s_chevereto:/var/www/html/images/
restart: always
env_file: .env_chevereto
depends_on:
chevereto_mariadb:
condition: service_healthy
expose:
- 80
environment:
CHEVERETO_DB_HOST: chevereto_mariadb
CHEVERETO_DB_PORT: 3306
CHEVERETO_HOSTNAME_PATH: /
CHEVERETO_HTTPS: 0
CHEVERETO_ASSET_STORAGE_TYPE: local
CHEVERETO_ASSET_STORAGE_BUCKET: /var/www/html/images/_assets/
CHEVERETO_MAX_POST_SIZE: 2G
CHEVERETO_MAX_UPLOAD_SIZE: 2G
volumes:
db_chevereto:
s_chevereto:
networks:
chevereto:
thatweicom_app-network:
external: true
.env_chevereto
MARIADB_ROOT_PASSWORD=your_root_password
MARIADB_USER=your_chevereto_db_user
MARIADB_PASSWORD=your_chevereto_db_password
MARIADB_DATABASE=db_chevereto
CHEVERETO_DB_USER=$MARIADB_USER
CHEVERETO_DB_PASS=$MARIADB_PASSWORD
CHEVERETO_DB_NAME=$MARIADB_DATABASE
CHEVERETO_HOSTNAME=your_domain_for_image
CHEVERETO_ASSET_STORAGE_URL=https://${CHEVERETO_HOSTNAME}/images/_assets/
Nginx
保存成chevereto.conf, 放到nginx的conf.d/里,重启nginx。(注意配置只支持https)
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name img.*;
server_tokens off;
# 记得改ssl cert / rmb to update ssl cert
ssl_certificate /etc/letsencrypt/live/ssl/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ssl/privkey.pem;
include /etc/nginx/conf.d/options-ssl-nginx.conf;
client_max_body_size 10m;
location / {
resolver 127.0.0.11;
set $upstream_app chevereto;
set $upstream_port 80;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
}
}
完成安装
访问你的图床域名测试,第一次访问的时候会让你设置用户名之类的,之后就可以上传使用了。
可能遇到的问题
Error 526: invalid SSL certificate
我用的Cloudflare + SSL/TLS = “Full (strict)”,第一次访问图床的时候遇到了“Error 526: invalid SSL certificate”。测试发现主域名(https://thatwei.com)没问题,研究了半天怀疑是Chevereto本身用http的原因, 但也没找到好的方法把Chevereto改成https。。最后找到个临时新加了一条Rule把“img.thatwei.com” SSL/TLS模式改成了“Full” (thatwei.com还是Full strict)。