Docker series uses Docker to build a lightweight file sharing system based on go-file that supports user authentication
本文最后更新于 345 天前,其中的信息可能已经有所发展或是发生改变,如有失效可到评论区留言。

Preface

As for apps that can share files, I have introduced several of them before. The most complex one is minio on the private COS platform (I mainly use it to provide downloads of large files. After all, minio's permanent file links need to be generated manually, which is slightly slow and inefficient. For specific configuration steps, see:Docker series builds a private COS platform based on minio), lightweight ones include pingvin-share (I mainly use it to store small files that need to be shared on my blog. For specific configuration steps, see:Docker series uses Docker to deploy a lightweight file sharing platform based on pingvin-share), and I usually send texts and small files to friends using the self-destructing function provided by cryptgeon (for specific configuration steps, see:Docker series: Use Docker to build your own self-destructing application based on cryptgeon), to be honest, it is basically enough to cope with various daily scenarios.

However, the only drawback is that when I send text or files to friends, I always feel a little sneaky when using the self-destructing app. I am a little afraid that the Internet monitoring will misunderstand that I am doing something bad. . . Moreover, the self-destructing apps basically do not require registration, so I dare not use them openly (after all, the host name of the link will expose my website address), and I am afraid that I will be investigated if I use it improperly (you need to be careful when living in China). Although pingvin-share supports registration, it is essentially sharing a folder with a fixed link. Although you can also create a new link each time to share a single file, the operation is a bit complicated and it feels like using a cannon to kill a mosquito, so I personally think it is best used on blogs.

So is there an app that can be used to share files with friends, users or other people? Today I accidentally discovered go-file.

This article introduces a lightweight file sharing app that supports user authentication: go-file.

Deploy go-file

Create a directory on the host that needs to be mounted inside the container

mkdir -p /docker/go-file/data

This directory is also used to store videos, files, pictures, etc. that need to be shared, so try to choose a good storage location according to your needs.

Building go-file

The command to build go-file in docker run format is as follows:

docker run --name go-file -d --restart=always \ -p 3000:3000 \ #Map port 3000 on the host to port 3000 inside the container. Please modify according to the actual environment -e TZ=Asia/Shanghai \ #Set the container time zone -v /docker/go-file/data:/data \ #Set the directory justsong/go-file on the host to be mounted inside the container

Publish go-file to the public network using an appropriate method (optional)

Unless it is only used in a local area network, go-file must be published 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).

Assume that the access method of go-file after release ishttps://example.com

Access and configure go-file

usehttps://example.comAccess go-file (access via http://host ip:3000 in LAN), the interface is as follows:

image.png

For the first visit, click "Login" in the red box in the upper right corner of the above picture. On the user login interface, use the default username "admin" and the default password "123456", and then click "Submit":
image.png

After logging in, click "System Management" under the "Admin" menu in the red box in the upper right corner:
image.png

Then modify the default administrator password (note: changing the display name does not change the account username), and then click "Submit":
image.png

The "Account Management" interface in the above picture can also add "Ordinary User" and "Administrator User":
image.png

And "Manage Users":
image.png

In "System Settings", you can set the minimum permissions required for uploading and downloading:
image.png

If you only use it for yourself, you can select administrator for both "File Upload" and "Image Upload". I chose "Ordinary User" as the minimum permission for uploading because I considered that my friends can also use it, as shown below:
image.png

Share files using go-file

Share text files

Why do we need to talk about text files separately? Because this involves another application mode: direct call under the terminal.

For example, if you want to paste a piece of code into the server, but you are worried about various character formatting issues, you can directly upload the txt text file to go-file, and then use wget https://example.com/xxxxxxxx.txt -O file_name to download the text file directly to the local computer and rename it; or if you have installed a new server without a graphical interface, without sshd service, and no editor is available to edit the sources.list file, and it is too slow to install an editor directly using the default source, you can use curl https://example.com/xxxxxxxx.txt > /etc/apt/sources.list or wget https://example.com/xxxxxxxx.txt -O /etc/apt/sources.list To update the apt source, and then use apt update to update, or other scenarios such as this. In theory, minio can also be used, but the steps are relatively cumbersome and not as convenient as go-file.

In fact, when it comes to this function, pasteme used to be the most convenient, but it no longer works after being invited for tea.

Sharing text is very simple, just click "Upload" in the red box in the upper right corner:

image.png

There are two ways here. One is to copy the text directly to "Description Information" and then click Upload, which will be automatically generated. You can also use the selection in the red box below to select a local text file and click Upload:
image.png

After uploading, just click the copy button in the red box on the right to get the file address:
image.png

After obtaining the file address, you can then operate it in the several ways described above.

Share video files

In fact, the steps for uploading are the same, but after uploading the video file, in addition to sharing it using the sharing link, you can also play it online directly through the video menu:

image.png

Of course, this is actually played directly by the browser, so a format supported by the browser is required (or a player must be installed).

Simple image hosting function

In the image hosting menu, you can directly copy and paste or drag and drop to upload images:

image.png

Why is it called a simple image hosting? Look at the red box on the right, there are only two formats, one is http(s) or markdown:
image.png

Judging from the image link provided, it looks extremely simple compared to chevereto:
image.png

image.png

Not to mention that chevereto has other functions. However, although it is simple, it also provides plug-ins that work with picgo:
image.png

In general, I can only say that it is usable. You can choose it according to the situation.

Online Preview

If you upload the file directly on the homepage, you can preview it online:

image.png

Why do I say on the homepage? Because by default, go-file only has one image folder, which is used to store the images uploaded under the image hosting menu, and other directly uploaded files are in a folder named "year-month" automatically generated by the system. The files in this automatically generated folder can be directly seen on the homepage, and can be deleted, shared by QR code, copied link address, previewed online and downloaded directly, as shown in the 5 icons in the lower right corner of the above picture.

Upload files in the folder you created

If you are in the host system/docker/go-file/data/uploadCreate other folders in the directory. For example, I created three folders, file, text, and video, according to my habit. Then, select the "File" menu of go-file and you will see the new directory:

image.png

The files in the blue box below the above picture are automatically generated by the system, and the files in the red box are created directly on the host machine. Files uploaded to the folders you created will not appear on the homepage, so you cannot directly delete them on the page, generate QR codes, or preview them online. You can only enter the folder to download and copy the sharing link:

image.png

If you don't want the uploaded files to be displayed on the homepage, you can use this method.

Summarize

Overall, go-file has made up for my shortcomings when I usually share files with others. I am very satisfied with the fact that it supports user authentication. Finally, I have a tool that I can share with others openly. If I upload files in a self-built directory, they will not be visible on the homepage, and privacy is guaranteed. At the same time, I also connected the application to cloudflare for traffic cleaning through a custom host name, so I am not afraid of attacks. It's perfect.

However, there are some minor regrets, such as the complete lack of file management functions. Except for files uploaded on the homepage, which can be deleted directly on the page, files uploaded in folders created by oneself can only be deleted on the host machine. . At the same time, it does not support sharing with passwords, nor does it support the number of readings and time control. . . At the very least, there is an option to control whether the homepage displays visitor files. This is indeed a bit painful. Even if I upload a file on the homepage, I don’t want everyone to be able to access it. I may just want to share it through a link? In this regard, peertube’s video sharing is good:

image.png

I hope go-file can add these features in the future.

The content of the blog is original. Please indicate the source when reprinting! For more blog articles, you can go toSitemapUnderstand. The RSS address of the blog is:https://blog.tangwudi.com/feed, welcome to subscribe; if necessary, you can joinTelegram GroupDiscuss the problem together.
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠(ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ°Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Emoticons
Emoji
Little Dinosaur
flower!
Previous
Next
       

This site has disabled the right mouse button and various shortcut keys. The code block content can be copied directly by clicking the copy button in the upper right corner

en_US