Build Syncthing: Quickly implement open source file synchronization and remote control

1 Introduction

In the current era of data explosion, massive amounts of data are generated every day. These data may be new photos taken in our mobile phones, file files received at work, documents edited and written by hand, or newly downloaded videos. It can fill up smart devices (mobile phones, tablets, etc.) with worrying capacity. Because of this, cloud storage has been in the limelight for a while. It not only allows these massive data to have a place to stay, but can also share it with those who need it at any time. However, cloud disks from big manufacturers always have many problems, so they can only build their own cloud disks to ensure safety.

In fact, the current private cloud disk software has been developed very well, which can not only meet the basic large-capacity storage needs, but also not suffer from speed restrictions. Of course, some private cloud disk software can also provide many special functions. Today, the author will introduce to you how to install Syncthing, a software that can synchronize and backup data by itself, and how to cooperate with cpolar, so that we can operate Syncthing on the public Internet.

2. Syncthing website construction

Syncthing is very similar to the well-known Resilio Sync, both of which are based on P2P distributed technology, which enables real-time synchronization of files between devices (you can also choose a device to upload files only). However, from the point of view of its functional design, it may be more inclined to the "file/folder" synchronization tool, but it does not prevent us from using it as a cloud disk server tool.

2.1. Syncthing download and installation

Although Syncthing is controlled by a web page, its installation does not need to put web files into the running environment like other web deployments, but directly provides a very convenient .exe file installation method for Windows systems (why Speaking of Windows? Because the author uses Windows), we only need to download the corresponding operating system software on the download page of its official website [ https://syncthing.net/downloads/ ]. Of course, Syncthing also provides software downloads for other mainstream operating system versions.

20230428105001

20230428105002

20230428105003

After downloading the Syncthing software compressed package, unzip the compressed package, find the Syncthing.exe program in the decompressed folder, and double-click to run it. During the installation process, Windows Firewall may pop up asking, we just need to allow access.

20230428105004

20230428105005

After the installation process is over, Syncthing will automatically open port 8384 of the browser (the default output port of Syncthing), and enter the main interface of Syncthing, where we can configure Syncthing, such as synchronizing content, device access, and so on.

20230428105006

On the settings page, we can also find the output port number of Syncthing, and our subsequent operation is mainly to turn this Syncthing page, which can only be accessed within the LAN, into a private cloud disk entrance that can be accessed on the public Internet.

20230428105007

Reprinted from cpolar pole cloud article: Build a free automatic file synchronization server, remote access without public IP IP [Syncthing private cloud disk] - cpolar pole cloud

2.2. Syncthing web page test

Of course, in order to make sure that we can access the Syncthing webpage in the LAN and ensure that the Syncthing webpage is running correctly, we can conduct a small test, that is, enter the Syncthing address + port number in the incognito mode of the browser, and if the Syncthing can be accessed normally Web page, which proves that our Syncthing can run normally

20230428105008

It should be noted that when Syncthing is not added to the Windows service list and enabled to run in the background, the command line window needs to be kept running. If it is closed, Syncthing will terminate.

2.3.cpolar installation and registration

After completing the installation of Syncthing, you can move to the installation of cpolar. Like Syncthing, the installation and registration of cpolar is also very simple. We can find the "Download" button directly on cpolar's official website page.

cpolar official website: https://www.cpolar.com/

20230428105009

The author is using the Windows operating system, so I chose the Windows version to download.

After the Cpolar download is completed, unzip the downloaded file and double-click the decompressed .msi file to automatically execute the installation program. Then just click "Next" to complete the installation.

20230428105011

20230428105012

Since cpolar will create an independent data tunnel for each user, supplemented by user passwords and token codes to ensure data security, we need to register users before using cpolar. The registration process is also very simple. Just click "User Registration" in the upper right corner of the cpolar homepage and fill in the necessary information on the registration page to complete the registration.

20230428105013

20230428105014

3. Local web publishing

Now that we have the Syncthing software that can run normally, and cpolar that can establish an intranet penetration data tunnel, we can use cpolar to create a public Internet address that can connect to the local test page, so that our Syncthing can Set up operations on the public Internet.

3.1. Cpolar cloud settings

File synchronization may be random and continuous, and the data tunnel of the single cpolar free version resets every 24 hours. I believe that no one wants to reconnect the data tunnel every day, so you can upgrade the penetration puller to the VIP version in order to obtain an intranet penetration data tunnel that can exist stably for a long time.

In the next step, we set about setting up the intranet penetration data tunnel. To obtain a long-term and stable intranet penetration data tunnel, you need to log in to the official website of cpolar, and find the "Reserve" button on the left side of the user home page, and click Enter cpolar's data tunnel reservation page.

A public Internet address is generated here (can also be regarded as the entrance of the data tunnel). Since this address is not connected to the local software output port at this time, it can also be regarded as a blank data tunnel.

20230428105015

On the reservation page, you can see many types of data tunnels that can be reserved. Here we select the "Reserve second-level subdomain name" field.

20230428105016

In the "Reserved second-level subdomain name" field, several simple settings of information need to be made. The settings are as follows:

  • 地区: The area where the server is located, just select the nearest one
  • 二级域名: Will eventually appear in the generated public Internet address as one of the identifiers of the network address
  • 描述: Can be seen as a description of this data tunnel, as long as it can be distinguished from other tunnels

After completing these settings, you can click the "Reserve" button on the right to retain this data tunnel.

20230428105017

Of course, if you no longer plan to use this data tunnel, you can click the "x" on the right to easily delete it and save valuable tunnel quota.

20230428105018

3.2.Cpolar local setting

After completing the settings of the cpolar cloud and retaining the blank data tunnel, we open the local cpolar client and connect the blank data tunnel generated by the cloud to the local test page.

After opening and logging in to the cpolar client locally (you can enter localhost:9200 in the browser to access it directly, or you can click the cpolar client shortcut in the start menu).

20230428105019

Click the "Create Tunnel" button under the "Tunnel Management" item on the left side of the client's main interface to enter the local tunnel creation page (if you want to create a temporary data tunnel, you can set it up directly here without logging in to the cpolar official website to set up a blank data tunnel).

On this page, you also need to make several information settings, which include:

1. 隧道名称– It can be regarded as cpolar’s ​​local tunnel information annotation, as long as it is convenient for us to distinguish;
2. 协议– Since Syncthing is displayed on a web page, the http protocol is selected;
3. 本地地址– The local address is the output port number of Syncthing, and Syncthing The default output port is 8384, so fill in 8384 here;
4. 域名类型– In this example, we have reserved a data tunnel for the second-level subdomain name in the cpolar cloud, so check “Second-level subdomain name” (if reserved If it is a custom domain name, check the custom domain name), and fill in the reserved second-level subdomain name in the "Sub Domain" column on the next line, which is "Syncthingweb" in this example (if you plan to create a temporary data tunnel, directly Check "Random domain name", and the cpolar client will generate the network address by itself);
5. 地区- The same as the information reserved in the cpolar cloud, we can fill it in according to the actual place of use;

20230428105020

After completing these simple settings, you can click the "Create" button at the bottom of the page to connect the blank data tunnel in the cpolar cloud with the local Syncthing page.
We can manage this data tunnel on the "Tunnel List" page under "Tunnel Management", including opening, closing or deleting this tunnel, or click the "Edit" button to update the information of this data tunnel to modify.

20230428105021

4. Public network access test

Finally, we click the "Online Tunnel List" button under the "Status" item on the left to find the public Internet address of this page.

20230428105022

However, Syncthing has a host header check function, so we also need to make a small modification to the data tunnel of cpolar to access the local Syncthing web page on the public Internet. We return to the "Tunnel List" page under the "Tunnel Management" item, find "Edit" of the "Syncthing Page", and select

20230428105023

Enter the "Syncthing Page", click the "Advanced" button, and edit a new host header for this data tunnel.

20230428105024

Click on the "Advanced" setting page, find the "Host header field", and fill in the Syncthing's local webpage address in the space, that is, "localhost:8384", so that when public Internet visitors access the local Syncthing webpage through cpolar, cpolar can reset Write the host header. After filling in, click the "Update" button at the bottom of the page to save the host header changes we made.

20230428105025

After completing the setting of the host header, we return to the "Online Tunnel List" page, find the public Internet address of the Syncthing page, paste this address into the browser, and then we can see the local Syncthing page, allowing us to be on the public Internet, Visit the Syncthing page.

20230428105026

20230428105027

5 Conclusion

Of course, using the data tunnel created by cpolar to access the local Syncthing page is not the only use of cpolar. We can use cpolar to create any intranet penetration data tunnel pointing to the local tcp or http port, and publish the local web page or software to the public Internet.

Reprinted from the cpolar pole cloud article: [File Synchronization Tool - Locally Build a Free and Open Source Syncthing Automatic File Synchronization Server [Remote Access]](File Synchronization Tool - Locally Build a Free and Open Source Syncthing Automatic File Synchronization Server [Remote Access] - cpolar pole cloud )

Guess you like

Origin blog.csdn.net/weixin_46703995/article/details/132228945