After establishing your own blog, there are often many images in the blog. Storing them locally will delay the loading speed of the blog and occupy server space, so many people choose to use an image hosting service. However, many image hosting services on the market are unstable, such as the incidents of the previous Sina Image Hosting and Gitee going down, which caused heavy losses for many users of image hosting services. Moreover, image hosting services have unstable speeds and many restrictions, such as image size, the number of files transferred in a single upload, and some image hosting services even have speed limits. The most important thing is that image hosting services can only upload images, and some videos and PDF resources cannot be uploaded. Therefore, we can use Backblaze B2 object storage, which is free, fast, and very secure.
- Registration.
First, open https://www.backblaze.com/b2/sign-up.html and register for B2 cloud storage. If you are not using a VPN and have a domestic IP, you may need to verify your domestic mobile phone number, which will incur a cost of approximately 0.1.
Backblaze pricing (Baidu image search)
-
Creating storage.
Click on "Buckets" and then create a new one.
Creating storage in Backblaze B2
After creating the bucket, you can set Bucket Settings, Lifecycle Settings, CORS Rules, etc.
Click on "Browse Files" to upload and download files.
Click on the uploaded file, and you can see the URL link of the file, which can be shared.
Backblaze B2 supports setting snapshots for files, which is not available in other cloud storage services.
Backblaze B2 can also use the S3 protocol to quickly upload and download files. -
Binding Cloudflare.
If your Backblaze B2 has a large amount of traffic, you can also integrate Backblaze B2 with CloudFlare CDN, set up caching policies, and let the traffic go through CloudFlare CDN to save on traffic fees. First, you need to set up domain DNS resolution in CloudFlare.
3.1 CloudFlare integration
My Backblaze B2 domain is f000.backblazeb2.com, so I added a CNAME record in CloudFlare with the record value as f004.backblazeb2.com.
Setting DNS resolution for Backblaze B2 in CloudFlare
Set up domain resolution to f004.backblazeb2.com/ in Cloudflare (depending on the specific situation)
Adding resolution records for Backblaze B2
3.2 Setting up caching policies
Go to the CloudFlare official website to view your domain, click on Page Rules, and then click on Add a Rule.
(1) Adding a rule for Backblaze B2
URL: https://yourwebsitedomain/file/backblazebucketname/* (i.e., all files in that directory, you can set it according to your actual situation), cache level set to cache everything.
(2) Caching everything for Backblaze B2
Then, you also need to add a cache time in Backblaze B2 at Bucket Info:. The longer the time, the longer the file will be cached on the CloudFlare CDN node, in seconds. Set it according to your needs.
{"cache-control":"max-age=720000"}
As shown in the following figure:
backblaze_15.webp
- Summary
There are many foreign cloud storage services, and the advantage of Backblaze B2 lies in its cheap price and free quota. Registering and applying for a Backblaze B2 account is also very easy, without the need for credit card verification, and the free capacity is sufficient for a small blog. There are many plugins and services on the market that support the Backblaze B2 API, so WordPress users can completely use Backblaze B2 as attachment and backup storage. Backblaze B2 combined with CloudFlare can not only accelerate but also save traffic. If you find that your B2 encounters an error after using Cloudflare: "This webpage has a redirect loop," remember to set SSL/TLS in Cloudflare to Full (default is Flexible).
(The content of this article, except for the summary section, is referenced from Wazhanfou, and all other content is original. Some images are selected from the search results of Baidu Images.)