向诚

向诚

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

Use Mix Space's file system for storing static resources.

There is a file system in the Mix Space backend, as shown below:

image

In fact, this file management system directly relies on a folder deployed by Mix Space, which is located at mx-space/static/, and the icons, avatars, and files correspond to avatar, icon, and file, respectively. So if you directly perform file operations on these three folders, they will also be synchronized in the Mix Space backend. For this feature, this site currently uses FTP+PicList to set up the image hosting service. The following is the sharing operation process.

PicList is a modification of PicGo, so this tutorial is also applicable to PicGo.

This site uses 1Panel+Docker to deploy Mix Space. The container file directory format of 1Panel is generally /opt/1panel/docker/compose/container_name/data/. Please judge and handle according to your own server situation. For FTP, you only need to configure the file directory and authentication operation.

image

Next, download the ftp-uploader plugin in PicList and configure it. Here is a json configuration example that uses the backend domain name for resource access:

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

If you use an independent domain name for access like me, you still need to use reverse proxy. Here is my deployment plan, please modify it according to your actual situation.

# Nginx reverse proxy configuration

location ^~ /shiro/files/ { # Reverse proxy folder (customized)
    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

When the frontend request path is /shiro/files/, all requests for https://domain/shiro/files/ on this website will be reverse proxied to the Mix Space resource folder, achieving the effect of accessing static resources with an independent domain name. Reverse proxy configuration can be added for avatar, icon, and file.

// ftp-uploader plugin configuration

{
  "img": {
    "url": "https://domain", //Your independent domain name
    "path": "/shiro/files/{fullName}", //Folder to be reverse proxied
    "uploadPath": "/{fullName}",
    "host": "serverIP",
    "port": 21,
    "username": "ftpuser",
    "password": "ftppass"
  }
}

This article is synchronized from Mix Space to xLog.
The original link is https://de3ay.com/posts/tech/mixspace-filesystem


Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.