How to customize the endpoints of the Pagoda Amazon S3 cloud storage plugin

Original link: https://mabbs.github.io/2022/12/12/bt-s3-comp.html

You can change the plug-in yourself if you know how to use Python!

cause

Last time I installed the pagoda panel with Koyeb and wrote some websites for testing on it, but because I like to modify it directly on the panel when I develop the website, basically there is no code backup locally, but recently the pagoda panel seems to have some problems. Less rumors about vulnerabilities, in order to avoid my website being destroyed due to various strange things, I want to order a plug-in for backup.

Plug-in use and modification

There are quite a lot of plug-ins in the Pagoda panel, and if you want to back up, there are also many supported platforms, and they are very user-friendly, and novices with functions can also operate them. However, considering the insecurity of the pagoda panel, I don’t want my frequently used network disk to be hung on it as a backup. If it is compromised, the files on my network disk will be taken away by others.

After comprehensive consideration, OSS or cloud disk is still not a good choice, but there are quite a few platforms compatible with S3 API. For example, 4EVERLAND, which I have used before , also has storage buckets. In addition, I registered a Filebase when I was shopping casually before, and it also supports it (both are 0 threshold and free 5GB). So want to use this to save my backup files.

However, the Amazon S3 cloud storage plug-in on the Pagoda panel can only use Amazon’s cloud services, and cannot change the endpoint… But I don’t want to sign up for AWS, except that it looks uncomfortable and inhumane, and it seems to be tied to a credit card for free use? (mostly I want to back up to Filebase, Or is it a waste of registration? ? )

So I went to look at the source code of this plug-in. Fortunately, the code is in Python, so it is not difficult to understand. At first, I wondered if it could access the AWS S3 endpoint directly through the HTTP API, so I searched directly, but after searching for a long time, I didn’t see a domain name related to AWS… It seems that opportunism is not good… You can only look at the code slowly. Finally, after searching for a long time, I found that it seems to use a library called boto3 to connect to AWS… The name is real… I can’t tell from the name that it has a half-money relationship with AWS (it seems because Boto is an Amazon puffer fish, it is said to be pink), especially its code is imported through from boto3 import client , there is no word related to boto3 in the code… The word client is very common, see this code It’s really uncomfortable…

But fortunately, at least I found the place to be changed in the end. In fact, it is very simple. Its “/www/server/panel/plugin/aws_s3/s3lib/client/aws_s3.py” file is the key to the introduction. The build_auth() method It is the key to connect to S3. I searched boto3 on the Internet. It also supports custom endpoints. Just add an endpoint_url parameter after line 100. For example, add an endpoint_url="https://s3.filebase.com" , after saving, configure the others on the panel.

feelings

Now you can see how rubbish the pagoda is. It can be done with just one parameter, but it just won’t add it for you, and it doesn’t support any functions, folders can’t be deleted, and there’s no way Upload/download files in the panel, and also install a boto3 dependency for you. It is too rubbish to install a full-featured dependency if nothing is supported. But Xiaobai doesn’t know how to write code, no matter how rubbish things should be used, right? ? .

This article is transferred from: https://mabbs.github.io/2022/12/12/bt-s3-comp.html
This site is only for collection, and the copyright belongs to the original author.