Contents
Preface
For building a website in a home data center, having your own image storage is a must: first, saving money is the bottom line, and you would never spend money to borrow someone else's help if you can build it yourself; second, in the future, you will need to refine the regional processing of image storage access (return different image storage cache addresses according to the source addresses of access from China and abroad), and you will also need your own image storage (I will explain this in detail in another article later, and it requires the dynamic redirection of cloudflare). For the construction of the image storage, I chose the docker version of chevereto to implement it.
In fact, almost all applications can be deployed through source code, but I will give priority to deploying applications as long as there is a docker version. After all, I have a dedicated docker deployment environment, which is convenient for deployment and migration. The source code deployment method is only an alternative method that I will use when docker deployment is inconvenient or there is no docker version at all, such as deploying V visa-free (see my other article:Linux panel series: Deploy V-sign-free in source code based on Baota panel).
deploy
Initialize the database
If you use docker-compose to deploy, there is no such step, because the database has been initialized in the corresponding docker-compose.yml file. If you use docker run to deploy, you will be asked to enter the relevant information of the database when you log in to chevereto for the first time, including host name, database name, username and password, etc. Therefore, if you use docker run, you need to have an existing mariaDB (or mysql) database (or create a new one) and initialize it yourself. For detailed initialization steps, please refer to my other article:Tips and tricks: Create a new empty database and grant permissions to corresponding users.
If there is no existing database, 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 \ #Map the host port to port 80 inside the container. Please modify it according to your actual situation -v /docker/mariadb/db:/var/lib/mysql \ #Map the specified folder of the host to the /var/lib/mysql directory inside the container -e MARIADB_ROOT_PASSWORD=yourpassword \ #Specify the root user password mariadb:10.11
Note: Please delete the comment after #
Assume that after initialization, the data information is as follows (all of these need to be filled in according to your actual configuration):
Database host : 192.168.10.130 (IP address of the host machine where the mariaDB container is located. If it is deployed locally, it is 127.0.0.1. If no port is specified, the default port is 3306. If it is not 3306, use :port to specify the actual port mapped on the host machine)
Database name: chevereto (chevereto library name)
Database user: chevereto (the user name of the user with full operation permissions corresponding to the chevereto database)
Database user: chevereto (the password of the user with full operation permissions corresponding to the chevereto database)
Database table prefix: chv_ (If the same chevereto library is used by multiple chevereto containers at the same time, a prefix is needed to distinguish the tables used by different containers)
Create a folder on the host that needs to be mapped to the chevereto container
It is customary to first create the -v parameter to mount the required folder:
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 \ #Map the host port to port 80 in the container. Please modify it according to your actual situation -e TZ=Asia/Shanghai \ #Set the container time zone -v /docker/chevereto/config:/config \ #Map the host specified folder to the /config directory in the container -v /docker/chevereto/data:/data \ #Map the host specified folder to the /data directory in the container linuxserver/chevereto:latest
In addition: If you want to use it with PicGo and an editor (such as obsidian) to realize the automatic upload function of copying and pasting pictures, you also need a line of -v parameter:
-v /docker/chevereto/config/route.api.php:/app/chevereto/app/routes/route.api.php
However, you need to create a container first./app/chevereto/app/routes/route.api.phpFiles are copied from the container to the host machine/docker/chevereto/configDirectory, then delete the container, re-add this line of -v parameters to re-create the container, you can refer to the following docker command:
docker cp chevereto:/app/chevereto/app/routes/route.api.php /docker/chevereto/config
Note: Please delete the comment after #
Initialize chevereto
passhttp://host ip:8090To log in:

The above information is filled in according to the information when initializing the database. If the database configuration is correct, the following interface will be displayed:

After configuration, click "install Chevereto" at the bottom to complete the installation. A successful installation will display the following interface:

Chevereto installation is now complete. Clicking "admin dashboard" in the red box will redirect you to the login screen.

Log in using the admin username and password configured previously:

Click on "Settings" in the red box above:

“"HTTPS" specifies whether Chevereto returns links via HTTP or HTTPS. The default is "Automatic," but you can also choose "Disabled" or "Forced." "Default time zone" specifies the time zone; for China, change it to "Asia/Shanghai." Finally, remember to click "Save changes" in the red box at the bottom to save your configuration changes.
One important point to emphasize in this interface is the "HTTPS" option. The default is Automatic, which automatically detects HTTPS and is the recommended option. However, in actual use, when accessing via a reverse proxy using HTTPS, I encountered the following display:

Unlike the login interface we saw earlier, this is because the browser receives an HTTP request from Chevereto instead of an HTTPS request. This is normal, as the reverse proxy points to the Chevereto container at an HTTP address. Therefore, Chevereto detects only HTTP requests from the reverse proxy, and the "Automatic" function can only detect HTTP, so it returns an HTTP address.
There are two solutions to solve the above problems:
1. Directly change Chevereto's "HTTPS" option to "Forced".”
This is the simplest method. If the image hosting service uses a reverse proxy and all external addresses are HTTPS, then selecting "Forced" is perfectly fine. However, if some are HTTPS and some are HTTP—for example, if there are two external domains, each corresponding to a reverse proxy, one HTTPS and the other HTTP—then "Forced" cannot be selected. You can only select "Disabled" or "Automatic." In this case, you can only resolve the issue by configuring the HTTPS reverse proxy, as detailed in the next section.
2. Configure on the reverse proxy
Configure it on the reverse proxy that is https externally. If it is nginx, you need to add a line to the reverse proxy configuration. You can refer to my other article:Docker series solves the problem that chevereto is deployed behind a reverse proxy and works abnormally.
Create an album
Click the username "Admin" in the upper right corner (highlighted in red), and then select "Albums" 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, the album name can be anything. I named it "blog" because this album is used to store images from blog posts. The key is the "Album privacy" option, which is set to Public by default. Since this album contains images from my blog, I set it to private (anyone can access it via a link). The first album you create has an ID of 1. This is needed when using it with other apps, such as when using PicGo to automatically upload screenshots or when setting up the Chevereto uploader. If you create albums later, you'll have to search for album IDs in Chevereto as you accumulate more albums. Therefore, it's better to create your primary album from the beginning, so the ID will be 1 from the start.
If it is an album created later, the id can be found in the album's Full info:

upload image
Uploading images is simple; just click the "upload" button in the red box at the top right of any screen.

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 through the URL of the online image. However, many image hosting services are set up to prevent hotlinks, so adding images using the URL may not work well. Taking adding from local as an example, batch adding is supported:

After selecting the picture, click Open in the lower right corner:

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

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

You can see the pictures you just uploaded. Double-click any picture to enter it. You can see picture links in various formats at the bottom:

Just select the format you need.
Configuring public network access
To publish to the public Internet, you need to choose the most suitable publishing method according to the actual environment and the reverse proxy you use. You can refer to my previous articles:
1,Docker series uses Docker to build its own reverse proxy based on NPM
2,Linux panel series configure reverse proxy and use non-443 port for publishing
3.Home data center series uses domestic cloud hosting to get free cloudflare to achieve fast access to domestic sites from abroad
4.Home Data Center Series: Use cloudflare to build a website quickly with no public IP in your home broadband (general purpose)
The first and second methods are suitable for environments with public IP but no legal 443 port (home broadband, unregistered cloud host). You need to add a non-standard port after the URL (if you use cloudflare to build a website, you don't need to add a port, but you need to customize the source station port. You can refer to:Home data center series uses cloudflare's Origin Rules to solve the problem of having a public IP but no legal ports 80 and 443 when building a websiteThe third method is suitable for cloud hosts with a record, and the fourth method is suitable for all environments (including environments without public IP), which is also the method I recommend (regardless of whether your environment has a public IP or not, because this method does not require running https traffic directly on the public network).
Afterword
In fact, chevereto has a wealth of functional options (such as adding image watermarks, which can be found in my other article:How to add watermarks to images using chevereto), but due to space limitations I will not elaborate on this.
In addition, the image upload method in this article is the most basic way to use the image hosting service, but under normal circumstances, this method is too inefficient. If there are dozens of images in an article, this method will be very time-consuming. The most efficient way is to use an image upload app such as PicGo and use it with your editor to achieve direct pasting and automatic upload and automatically generate image links in the editor. This requires the use of the API. For specific configuration, see my other article:Chevereto+PicGo+Obsidian is a series of tricks to achieve efficient image upload and image URL acquisition.