向诚

向诚

巷子里的猫很自由,却没有归宿。
telegram
email

使用Mix Space的檔案系統進行靜態資源存放

Mix Space 後台內有一個文件系統,示例如下:

image

實際上,這個文件管理系統直接依賴於 Mix Space 部署的某個文件夾內,它處於mx-space/static/這個位置,並且圖標、頭像、文件分別對應於avatariconfile 。所以如果直接對該三個文件夾進行文件操作,Mix Space 後台內也是可以被同步的。對於這個特性,本站目前使用FTP+PicList進行圖床的架設,下述開始分享操作流程。

PicList 二開於 PicGo,所以這份教程同樣適用於 PicGo。

本站使用 1Panel+Docker 架設 Mix Space,1Panel 的容器文件目錄格式一般是/opt/1panel/docker/compose/容器名/data/,具體情況請根據自己的伺服器進行判斷處理。那麼針對 FTP 只需要配置好文件目錄和鑒權操作即可。

image

繼續,在 PicList 內下載ftp-uploader插件並進行配置。下面是一份使用後端域名進行資源訪問的 json 配置樣例:

{
  "img": {
    "url": "getaway", //API 地址
    "path": "/api/v2/objects/*type*/{fullName}", //type:avatar,icon,file
    "uploadPath": "/{fullName}",
    "host": "serverIP",
    "port": 21,
    "username": "ftpuser",
    "password": "ftppass"
  }
}

若如我這般使用獨立域名進行訪問,依舊需要用到反代。下述是我的部署方案,請根據自身實際情況進行修改。

# Nginx反代配置

location ^~ /shiro/files/ { # 反代的文件夾(自定義)
    proxy_pass http://127.0.0.1:2333/api/v2/objects/file/; 
    proxy_set_header Host $host; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header REMOTE-HOST $remote_addr; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    proxy_set_header X-Forwarded-Proto $scheme; 
    proxy_http_version 1.1; 
    add_header X-Cache $upstream_cache_status; 
    add_header Strict-Transport-Security "max-age=31536000"; 
    add_header Cache-Control no-cache; 
}

image

當反代前端請求路徑為/shiro/files/時,該網站下所有的https://domain/shiro/files/請求將會反代 Mix Space 的資源文件夾,起到了獨立域名訪問靜態資源的效果。反代配置可以針對avatariconfile 進行多項反代配置的添加。

// ftp-uploader插件配置

{
  "img": {
    "url": "https://domain", //你的獨立域名
    "path": "/shiro/files/{fullName}", //需要反代的文件夾
    "uploadPath": "/{fullName}",
    "host": "serverIP",
    "port": 21,
    "username": "ftpuser",
    "password": "ftppass"
  }
}

此文由 Mix Space 同步更新至 xLog
原始連結為 https://de3ay.com/posts/tech/mixspace-filesystem


載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。