配置参考

PicFast 支持两种配置方式:config.yaml 或环境变量。环境变量始终优先于 YAML 配置。

完整示例

server:
  port: 8080
  base_url: "http://localhost:8080"
  web_dir: ""
  pprof_enabled: false

database:
  url: "postgres://picfast:picfast@localhost:5432/picfast?sslmode=disable"

jwt:
  secret: "change-me-in-production"
  access_ttl: 15m
  refresh_ttl: 168h
  signing_method: "HS256"

storage:
  local_root: "./data/uploads"
  thumbnail_dir: "./data/thumbnails"

mail:
  host: "127.0.0.1"
  port: 1025
  username: ""
  password: ""
  from_email: "noreply@picfast.local"
  from_name: "PicFast"
  encryption: "none"

app:
  name: "PicFast"
  site_description: "PicFast is a modern self-hosted image hosting service."
  favicon_url: ""
  allow_guest_upload: false
  allow_registration: true
  require_email_verification: true
  audit_upload_logs: false
  user_initial_capacity: 524288000
  guest_capacity_bytes: 10737418240
  default_image_ttl: "0"
  guest_image_ttl: "0"
  admin_email: ""
  admin_password: ""
  moderation_mode: "disabled"
  footer_text_1: ""
  footer_link_1: ""
  footer_text_2: ""
  footer_link_2: ""
  icp_number: ""
  icp_link: "https://beian.miit.gov.cn/"
  psb_number: ""
  psb_link: ""
  analytics_provider: ""
  analytics_config: "{}"

配置项说明

server

类型默认值说明
portint8080监听端口
base_urlstringhttp://localhost:8080服务公开访问地址。验证邮件链接和 ShareX 配置依赖此值,必须设为实际访问域名。
web_dirstring""前端静态文件目录(可选;自动检测 web-dist/web/dist/
pprof_enabledboolfalse开启 Go pprof 端点(/api/v1/admin/debug/pprof/*,仅管理员可用)

jwt

类型默认值说明
secretstringchange-me-in-production必填。必须修改。 使用默认值会导致启动时报错退出。生产环境请使用强随机密钥。
access_ttlduration15mAccess token 有效期
refresh_ttlduration168hRefresh token 有效期(7 天)
signing_methodstringHS256HS256、HS384 或 HS512

app

类型默认值说明
namestringPicFast站点名称,显示在页面标题、邮件和 Web UI 中
site_descriptionstring""Web UI 的 Meta 描述
favicon_urlstring""自定义站点图标 URL;空则使用内置默认图标
allow_guest_uploadboolfalse允许不登录上传
guest_capacity_bytesint6410737418240所有游客共享的总存储配额(10 GB)
allow_registrationbooltrue允许新用户注册。建议创建账号后关闭。
require_email_verificationbooltrue登录前必须验证邮箱。仅在 mail.* 配置正确且 SMTP 可达时生效。
audit_upload_logsboolfalse记录所有上传操作到审计日志
user_initial_capacityint64524288000新用户默认存储配额(500 MB)
guest_capacity_bytesint6410737418240所有游客共享的总存储配额(10 GB)
default_image_ttlduration0(永不过期)图片默认过期时间(如 24h168h;0 = 永不过期)
guest_image_ttlduration0(永不过期)游客上传图片的独立过期时间(0 = 使用 default_image_ttl;可设为 24h 等较短时间)
admin_emailstring""admin_password 同时设置后,首次启动自动创建管理员并跳过初始化向导
admin_passwordstring""自动创建的管理员账号密码
moderation_modestringdisabled"disabled"(默认关闭)、"manual"(人工审核)
footer_text_1string""可选页脚文字行 1;空则不显示
footer_link_1string""可选页脚文字行 1 的链接
footer_text_2string""可选页脚文字行 2;空则不显示
footer_link_2string""可选页脚文字行 2 的链接
icp_numberstring""ICP 备案号(适用于在中国大陆托管服务的站点)
icp_linkstringhttps://beian.miit.gov.cn/ICP 备案链接地址
psb_numberstring""公安备案号
psb_linkstring""公安备案链接地址
analytics_providerstring""""(关闭)、"plausible""umami""ga4""baidu""custom"
analytics_configjson""各服务商的独立配置(详见下方「统计分析」章节)

统计分析服务

PicFast 支持接入统计服务来追踪 Web UI 的访问情况。通过 app.analytics_providerapp.analytics_config 进行配置。

服务商配置字段
plausibledomain(必填),server_url(可选)
umamiwebsite_id(必填),script_url(必填)
ga4measurement_id(必填)
baidusite_id(必填)
customscript_html(原始 HTML/脚本字符串,会注入到每个页面中)

mail

类型默认值说明
hoststring""SMTP 服务器地址
portint1025SMTP 端口(587 = STARTTLS,465 = TLS,1025 = 本地 Mailpit)
encryptionstringnone"starttls""tls""none"
from_emailstringnoreply@picfast.local发件人地址;配置 SMTP 时必须填写
from_namestringPicFast发件人显示名称

关于邮箱验证

默认注册成功后立即登录。如需启用邮箱验证:

  1. 配置 mail.* 为有效的 SMTP 服务器
  2. 设置 app.require_email_verification = true

如果设置了邮箱验证但 SMTP 不可达,系统会退回普通注册流程,并在启动日志中输出警告。

本地开发推荐使用内置的 Mailpit(端口 1025 SMTP / 8025 Web UI),所有邮件都会拦截到本地收件箱,不会真的发到外部邮箱。