Preface
For building a home data center website, having your own image hosting is arguably a must-have: first, saving money is the absolute truth, and if it can be self-hosted, never spend money to rely on others; second, to later refine the geographical handling of access to the image hosting (returning different image hosting cache addresses based on whether the source address of the access is domestic or foreign) also requires having your own image hosting (I will explain this in detail in another article later, which requires using Cloudflare's dynamic redirection). For building the image hosting, I chose the Docker version of Chevereto to implement it.
Actually, almost all applications can be deployed via source code. However, as long as a Docker version is available, I will prioritize using it. After all, I have a dedicated Docker deployment environment, making deployment and migration much more convenient. Source code deployment is only an alternative I adopt when Docker deployment is inconvenient or when there is no Docker version at all, such as deploying V-Sign (see my other article:Linux Panel Series: A Dummy's Guide to Deploying V-Sign via Source Code Based on aaPanel)。
Deployment
Initialize the database
If you deploy using docker-compose, this step is not needed because the database is already initialized in the corresponding docker-compose.yml file. However, if you deploy using the docker run method, you will be prompted to enter database-related information, including host name, database name, username, password, etc., during the first login to Chevereto. Therefore, using the docker run method requires an existing MariaDB (or MySQL) database (or creating a new one) and initializing it yourself. For detailed initialization steps, please refer to my other article:Tips and Tricks Series: Creating a New Empty Database and Granting Permissions to Corresponding Users。
If you don't have an existing database yet, you need to create a new database container and then initialize the database. Refer to the following command:
docker run --name=mariadb -d --restart=always \
-p 3306:3306 \ #映射宿主机端口到容器内部的80端口,请根据自己实际情况修改
-v /docker/mariadb/db:/var/lib/mysql \ #映射宿主机指定文件夹到容器内部的/var/lib/mysql目录
-e MARIADB_ROOT_PASSWORD=yourpassword \ #指定root用户密码
mariadb:10.11
Note: Please delete the comments after # yourself
Assuming the database information after initialization is as shown below (you need to fill these in according to your actual configuration):
Database host : 192.168.10.130 (The IP of the host machine where the MariaDB container is located. If deployed locally, it is 127.0.0.1. Without a port, it defaults to port 3306. If it is not 3306, please use :port to specify the actual port mapped on the host)
Database name : chevereto (Chevereto database name)
Database user : chevereto (The username of the user with full operation permissions for the Chevereto database)
Database user : chevereto (The password of the user with full operation permissions for the Chevereto database)
Database table prefix : chv_ (If multiple Chevereto containers use the same Chevereto database simultaneously, you need to use a prefix to distinguish the tables used by different containers)
Create folders on the host machine that need to be mapped into the Chevereto container
As usual, first create the folders required for the -v parameter mount:
mkdir -p /docker/chevereto/config
mkdir -p /docker/chevereto/data
Deploy Chevereto
The docker run formula command is as follows:
docker run --name=chevereto -d --restart=always \
-p 8090:80 \ #映射宿主机端口到容器内部的80端口,请根据自己实际情况修改
-e TZ=Asia/Shanghai \ #设置容器时区
-v /docker/chevereto/config:/config \ #映射宿主机指定文件夹到容器内部的/config目录
-v /docker/chevereto/data:/data \ #映射宿主机指定文件夹到容器内部的/data目录
linuxserver/chevereto:latest
Note: If you want to use it with PicGo and editors (such as Obsidian) in the future to achieve automatic image upload via copy and paste, you also need an additional -v parameter line:
-v /docker/chevereto/config/route.api.php:/app/chevereto/app/routes/route.api.php
However, you need to create the container once first, and copy the/app/chevereto/app/routes/route.api.phpfile from inside the container to the host's/docker/chevereto/configdirectory, then delete the container, and recreate the container with this -v parameter line added. You can refer to the following Docker commands:
docker cp chevereto:/app/chevereto/app/routes/route.api.php /docker/chevereto/config
Note: Please delete the comments after # yourself
Initialize Chevereto
viahttp://宿主机ip:8090to log in:

Fill in the above information based on the database initialization details. If the database configuration is correct, you will enter the following interface:

After configuration, click ”install Chevereto” at the bottom to complete the installation. Upon success, the following interface will be displayed:

At this point, the Chevereto installation is complete. Clicking ”admin dashboard” in the red box will redirect you to the login interface:

Log in using the admin username and password configured earlier:

Click ”Settings” in the red box at the top:

“HTTPS” specifies whether the links returned by Chevereto to the outside use HTTP or HTTPS. The default is ”Automatic”, and you can also choose ”Disabled” and ”Forced”. ”Default time zone” is used to specify the timezone; for domestic users, change it to ”Asia/Shanghai”. Finally, remember to click ”Save changes” in the red box at the bottom to save the modified configuration.
One point that needs to be emphasized in this interface is the ”HTTPS” option. The default is "Automatic", which automatically detects HTTPS and is also the recommended option. However, in my actual use, when accessing via HTTPS through a reverse proxy, I encountered the following display:

It is different from the login interface we saw earlier. This is because the request returned by Chevereto received by the browser is HTTP instead of HTTPS. This is also normal because the address the reverse proxy points to for the Chevereto container is also HTTP. Therefore, what Chevereto detects are all HTTP requests sent by the reverse proxy, and what is detected through this ”Automatic” can only be HTTP, so it returns an HTTP address.
There are two solutions to solve the above problem:
Directly change Chevereto's ”HTTPS” option to ”Forced”
This is the simplest method. If the image hosting service's actual external address through the reverse proxy will always be HTTPS in the future, then choosing ”Forced” is perfectly fine. However, if some are HTTPS and some are HTTP—for example, if there are 2 external domain names corresponding to 2 reverse proxies, one using HTTPS and the other using HTTP—then you cannot choose ”Forced”. You can only choose ”Disabled” or ”Automatic”. In this case, you can only solve the problem by configuring it on the HTTPS reverse proxy, as detailed in the next section.
Configure on the reverse proxy
Configure on the reverse proxy that is externally HTTPS. If it is Nginx, you need to add a line to the reverse proxy configuration. You can refer to my other article for this:Docker Series: Solving the Issue of Chevereto Working Abnormally After Being Deployed Behind a Reverse Proxy。
Create an album
Click the account name ”Admin” in the red box in the upper right corner, and select ”Albums” in the red box from the drop-down menu:

The following interface appears:

Click ”Create new album” in the red box in the image above:

In the image above, you can fill in any album name. I named it ”blog” because this album is used to store images in blog posts. The key is "Album privacy", which defaults to Public. Since this album contains images for the blog, I set it to Private (anyone with the link can access it). The first album created will have an ID of 1. This is needed when using it with other apps, such as using PicGo to achieve automatic upload via screenshot pasting, or when setting up the Chevereto uploader. If you create albums later, you will have to look for the album ID in Chevereto when there are many albums. So, it's better to create the main-purpose album first, so its ID is directly 1.
If it is indeed an album created later, you can find the ID in the album's "Full info":

Upload images
Uploading images is very simple. On any interface, just click the ”upload” button in the red box at the top right of the page:

The following interface appears:

As can be seen from the two red boxes below, you can directly browse local images to add them, or add them via the URL of online images. However, many image hosting services have anti-hotlinking enabled, so adding via image URLs might not always work. Taking adding from local as an example, batch adding is supported:

After selecting the images, click "Open" in the bottom right:

Select the ”blog” album you just created, and then click "Upload" in the red box at the very bottom to complete the upload:

Click the ”blog” link in the red box above:

You can see the images just uploaded. Double-click to enter any image, and at the very bottom, you can see image links in various formats:

Just select the format you need.
Configure public network access
To publish to the public network, you need to choose the most suitable publishing method for yourself based on your actual environment and the reverse proxy you use. You can refer to several of my previous articles:
1、Docker Series: Building Your Own Reverse Proxy Based on NPM Using Docker
2、Linux Panel Series: Configuring Reverse Proxy and Publishing Using Non-443 Ports
3、Home Data Center Series: Getting Cloudflare for Free via Domestic ICP-Filed Cloud Hosts to Achieve Fast Access to Domestic Sites from Abroad
4、Home Data Center Series: Getting Cloudflare for Free via Home Broadband Without Public IP to Achieve Fast Website Building (Universal)
Among them, the 1st and 2nd methods are suitable for environments with a public IP but without a legal 443 port (home broadband, non-filed cloud hosts), where non-standard ports need to be added after the URL (if using Cloudflare to build a website, no port needs to be added, but you need to customize the origin server port, which you can refer to:Home Data Center Series: Solving the Problem of Having a Public IP but No Legal 80 or 443 Ports for Website Building via Cloudflare's Origin Rules). The 3rd method is suitable for cloud hosts with ICP filing, and the 4th method is suitable for all environments (including environments without a public IP), which is also my recommended method (regardless of whether your environment has a public IP, because this method does not require running HTTPS traffic directly on the public network).
Afterword
In fact, Chevereto also has rich functional options (such as adding image watermarks, which you can refer to in another article of mine:Tips and Tricks Series: Using Chevereto to Add Watermarks to Images), but due to space limitations, I won't expand on it.
In addition, the image uploading method in this article is the most basic way to use image hosting. However, under normal circumstances, this method is too inefficient. If there are dozens of images in an article, you will be exhausted using this method. The most efficient way is to use an image uploading app like PicGo in conjunction with your editor to achieve direct pasting, automatic uploading, and automatic generation of image links in the editor. This requires using the API method. For specific configuration, see another article of mine:Tips & Tricks Series: Achieving Efficient Image Uploading and URL Retrieval with Chevereto + PicGo + Obsidian。