Use Amazon cloud server EC2 and S3 free plans to build a private network disk

Netdisk is an online storage service that provides file storage, access, backup, contribution and other functions. It is an indispensable service in our daily life. Many Internet companies provide free network disk services for individuals and businesses. However, these free services have some limitations, such as limiting download speed, limiting file size, not being able to be managed by multiple people at the same time, and not being able to implement some customized functions. If you want to remove these restrictions, you have to pay. Now I will introduce to you a free private network disk with unlimited functions. We can use the open source network disk software NextCloud: Nextcloud - Open source content collaboration platform , and cooperate with the free service quota provided by Amazon Cloud Technology to build a private network disk with no usage restrictions. The tutorial is very simple. The installation process only requires three lines of commands. I hope it can help you.

Cost advantage

Due to the wide variety of Amazon cloud technology services and detailed billing, many users cannot understand it, so they are deterred from using Amazon Cloud. In fact, many Amazon Cloud Technology services have free packages to allow users to experience them. The free packages of these services are more than enough to build a private network disk. Since Amazon Cloud Overseas Area only requires a personal credit card to register, we take the overseas area as an example. We can see which Amazon Cloud  services have free packages from the following link : Amazon AWS overseas regional account free package_free cloud service-AWS cloud service:

image.png

The Amazon Cloud Technology Developer Community provides developers with global development technology resources. There are technical documents, development cases, technical columns, training videos, activities and competitions, etc. Help Chinese developers connect with the world's most cutting-edge technologies, ideas, and projects, and recommend outstanding Chinese developers or technologies to the global cloud community. If you haven't followed/collected it yet, please don't rush through it when you see it. Click here to make it your technical treasure trove!

The above table lists some of Amazon Cloud’s free service quotas. It can be seen that if you register a new Amazon Cloud account, you can use an EC2 instance host for free for one year, including 35GB storage space, and incoming traffic is completely free. , up to 1GB of monthly outgoing traffic is free. You may be worried about being charged if your monthly free quota is exhausted, so you can use the following settings to receive email alerts when your Amazon Web Services usage approaches or exceeds the Amazon Web Services free tier usage limit. Log in to your overseas Amazon Cloud Technology console, open the following link: https://console.aws.amazon.com/billing/home#/preferences?trk=cndc-detail  , and check "Receive free package usage reminders". Fill in your email address so you don't have to worry about incurring charges.

Technical advantages

As we all know, Amazon Cloud Technology provides stable enterprise-level cloud services to many multinational companies. Install the network disk on Amazon Cloud and rely on the enterprise-level services provided by Amazon Cloud to make the network disk performance more excellent and stable. NextCloud is an open source network disk application developed based on PHP. When you choose Amazon Cloud Technology's Graviton2 to run php7.4 version code, the performance increases by up to 30%. (Data source: Improving performance of PHP for Arm64 and impact on AWS Graviton2 based EC2 instances | AWS Compute Blog  ) In addition, Amazon S3, as a network disk storage medium, can reach 99.999999999% (11 9s) durability and is used all over the world. of companies store data for millions of applications. So, you don’t need to worry about data loss.

How-to: Creating an instance:

  • First, let’s choose an Amazon Cloud overseas region that is faster to access in China. Here we take Singapore as an example. Switch the region to Singapore in the upper right corner of the web page.

  • Click "Services" in the upper left corner of the web page, find EC2, and click it.

  • Click the "Launch Instance" button on the web page.

  • On the Select Operating System page, we select Ubuntu Server 20.04 LTS, and select the system version as ARM on the right. Click the blue "Select" button. Here we notice that if it is an operating system in the free package, it will be marked "Eligible Free Package".

  • On the Select Instance Type page, we select micro, where the letter g represents the Graviton2 chip. We see that this type is also marked with "free trial available". Click Next: Configure instance details.

  • Remove the checkbox after "Points Specifications" to avoid incurring additional fees. Click "Next: Add Storage."

  • On the Add Storage page, we change the root volume size to 30GB because the free tier provided by Amazon Cloud has a maximum limit of 30GB. Click "Next: Add tags."

  • There is no need to make any modifications to add a tab page. Just click "Next: Configure Security Group", select "Create a new security group", click the "Add Rule" button in the lower left corner, select "http" as the type, and confirm that the port range is 80 , the source is 0.0.0/0, which means it can be accessed by any IP. The following ::/0 represents IPv6. Click the blue button "Audit and Start" on the lower right.

  • On the verification instance startup page, click the "Start" button in the lower right corner. You will be asked to create a key to log in to the instance. Just follow the prompts to create and save it.

How-to guide: Assign a fixed IP

  • The instance created in this way is only assigned a temporary IP. We need to assign a fixed IP address to the instance. We click "Service" in the upper left corner and find the VPC.

  • Enter the VPC, click "Elastic IP" on the left, and then click "Assign Elastic IP Address" on the right to get a fixed IP address. Select this address, click the "Action" button, select "Associate Elastic IP Address", select the instance you just created on the association page, and associate the fixed IP with the instance you just created. Please note this fixed IP, you will use it to access the network disk later.

How-to: Install NextCloud

  • Returning to the EC2 service interface, we observe that the instance status is "Running" and the status check is "2 checks passed." It means it has been created successfully. Check the check box in front of the instance and click the "Connect" button on the right.

  • We use EC2 Instance Connect to log in to the EC2 instance from the browser. If it fails, use the language switch in the lower left corner of the console interface to switch the console interface to English to solve this problem. However, some regions do not support EC2 Instance Connect. If you encounter a region that does not support EC2 Instance Connect, you can refer to the "Connect to an instance" section in the tutorial below: Start an EC2 Linux instance

  • After logging in to the instance, first install the open source network disk software NextCloud and run the command:

sudo snap install nextcloud

  • After the installation is completed, it will prompt "nextcloud 22.1.1snap2 from Nextcloud✓ installed". The software installation is complete. You need to configure the username and password. Use the following command, where xiayan is replaced by your username and passw0rd is replaced by your password:

sudo nextcloud.manual-install xiayan passw0rd

  • After the configuration is completed, "Nextcloud was successfully installed" will be displayed. We now need to configure the trust domain. If you want to use IP to access the network disk, then after the following command "value=", you write the elastic IP you just configured. If you have your own domain name, you will use the domain name to access later, then the following Write your domain name after the command "value=", and point your domain name to the elastic IP just configured.

sudo nextcloud.occ config:system:set trusted_domains 1 --value=替换为您的 IP 地址或域名

  1. Now we can use a browser to open the IP address or domain name just now. Pay attention to using http. If the browser fails to open, you can try to enter the completed address, http:// plus the IP address. Log in with the username and password you just configured. However, the current interface is in English. You can click on the personal settings in the upper right corner to change the language to Chinese.

Operation Guide: Configure NextCloud backend storage as S3

  • So far, the network disk has been built, and 30G free EBS is now used as the network disk storage medium. If you need more space and better durability, we can configure the network disk to use S3 for storage. Click Personal Settings in the upper right corner, select "Applications", find External storage support in "Disabled Applications", and click "Enable".

  • Refer to  ent-M-DET How to Backup Files to Amazon S3 – Amazon Web Services  to create an S3 bucket. After creating the bucket, we also need to create an iam user. Click Services on the upper left and select IAM. Click "Users" on the left, then click the "Add User Button". Enter a username and select "Access Key" as the access type.

  • When adding permissions, we select "Attach existing policy directly", then enter "s3" in the filtering policy and check "AmazonS3FullAccess".

  • There is no need to make any changes later, just go to the next step to user creation. After prompting the user that the creation is successful, the "Access Key ID" and "Private Access Key" will be displayed. Please record it.
  • In personal settings, find "External Storage", select Add Storage, and select Amazon S3.

  • Fill in the name of the bucket just created and the region code of the bucket in the specified location. Make sure that the S3 and EC2 instances are in the same region, otherwise there will be additional charges. For region code query, please see this link: Region and Availability Zone - Amazon Elastic Compute Cloud.  You also need to fill in the "Access Key ID" and "Private Access Key" just recorded. Click the check mark on the right. If the addition is successful, the left There will be a green circular icon prompt, as shown below:

  • We can find the newly created Amazon S3 directory in the network disk list. The files in this directory are placed on S3 and have 11 nines of persistence.

in conclusion

At this point, the private network disk based on Graviton2 and S3 free packages has been successfully built. NextCloud has desktop, Android and iOS clients, which can be used for synchronization and backup. It also has a powerful multi-user system that can allow multiple people to work and share together, and can also be well integrated with WordPress, etc. This article is just an introduction, and there are many areas for improvement, such as configuring CloudFront CDN to accelerate network disk access. CloudFront also has a 50GB free package. You can also configure the network disk to https for more secure access. It is worth paying for a good product. According to this plan, even if the free package expires, the EC2 instance can be converted to an annual subscription for only 4.58USD per month, and the S3 storage only costs 0.023USD per GB per month.

Article source:
https://dev.amazoncloud.cn/column/article/650a7cf921a60a3e627e6b25?sc_medium=regulartraffic&sc_campaign=crossplatform&sc_channel=CSDN

Guess you like

Origin blog.csdn.net/u012365585/article/details/133141756