<\/figure>\n\n\n\nConsider selecting a user login that aligns with your account settings and optimal security; it’s advisable to use an account with minimal access rights.<\/p>\n\n\n\n
If you\u2019re not yet an AWS account holder, feel free to sign up; many new users qualify for complimentary access to select services under the AWS free tier.<\/p>\n\n\n\n
Step 2: Create a new AWS EC2 instance<\/h2>\n\n\n\n After signing in to your AWS account, use the search bar to type “EC2.” This will take you to the main page where you can set up and manage your resources.<\/p>\n\n\n\n <\/figure>\n\n\n\nNext, under Instances, you can select the option “Launch instances<\/strong>.”<\/p>\n\n\n\n <\/figure>\n\n\n\nOn the next page, you have the opportunity to choose extra settings, including the instance’s Name, Application, and OS Images. For our instance, we will go with the standard choice, which is Amazon Linux.<\/p>\n\n\n\n <\/figure>\n\n\n\nAn Amazon Machine Image, or AMI, is a preset virtual machine image with everything needed to launch a working AWS cloud instance. Think of it as a template for creating virtual servers, also known as EC2 (Elastic Compute Cloud) instances, making it simpler to duplicate server setups.<\/p>\n\n\n\n
“Free Tier eligible” implies that AWS permits users to access a certain amount of its services for free, either for a limited time or until you hit specific usage caps. This is a great way for new users to explore AWS, but it\u2019s important to keep an eye on your use and understand the limits to prevent any surprise costs when the free offerings are surpassed.<\/p>\n\n\n\n
As we continue to scroll down, we can choose our instance type. Amazon Linux requires a minimum of 512MB RAM and 1 CPU core. For test purposes, selecting the t2.micro instance would be a good fit since it falls under AWS\u2019s Free Tier.<\/p>\n\n\n\n <\/figure>\n\n\n\nIf your project and instance need to be ready for production use, you should opt for instances that offer more RAM and CPU capacity. You can do this by selecting from the available options in the dropdown menu.<\/p>\n\n\n\n
Step 3: Configure your EC2 instance<\/h2>\n\n\n\n We will continue with our setup process by configuring the security group for our instance.<\/p>\n\n\n\n <\/figure>\n\n\n\nEstablishing a new security group for your EC2 instance is a critical step toward ensuring optimal security within AWS. This practice enables you to set up and apply tailored network access rules, stick to the least privilege principle, and enhance the isolation and overall security of your EC2 instances.<\/p>\n\n\n\n <\/figure>\n\n\n\nMake sure to enter both the Key pair name and select the Key pair type, which could be RSA or ED25519.<\/p>\n\n\n\n
Both RSA and ED25519 are reliable choices for SSH key authentication. Your choice between them should be based on your security needs, compatibility requirements, and how much you trust newer cryptographic algorithms. Both options provide secure authentication for most situations when used properly. RSA is older, well-established, and works with a broad range of SSH servers and clients. ED25519, on the other hand, is an excellent option when security is paramount, and you don\u2019t need compatibility with older systems.<\/p>\n\n\n\n
Next, choose the Private key file format. You can pick between .pem format or .ppk if you’re using a Windows SSH client like PuTTy.<\/p>\n\n\n\n
For our purposes, we will go with the .pem format since we are using a terminal.<\/p>\n\n\n\n
Once everything is set, click “Create key pair” to generate your SSH key, and this will start a download through your browser. Note, AWS warns you to keep your private keys in a secure but reachable location on your computer.<\/p>\n\n\n\n
As we move forward with our setup, the next step is to configure our Network settings.<\/p>\n\n\n\n <\/figure>\n\n\n\nFor the initial setting, we aim to connect to our EC2 instance via SSH. However, instead of setting it to accept SSH traffic from “0.0.0.0\/0” (which opens the connection to any location), we should narrow it down to accept connections solely from trusted, specific IP addresses or ranges. This precaution minimizes the potential exposure of your SSH port on the internet, diminishing the chances of unauthorized access. You can specify the allowed IP ranges using CIDR notation, such as “192.168.1.0\/24.”<\/p>\n\n\n\n
Additionally, since our plan includes setting up an Nginx web server as a practical demonstration, be sure to select the option to “Allow HTTP traffic from the internet.”<\/p>\n\n\n\n <\/figure>\n\n\n\nNext, we can select our storage options from the menu:<\/p>\n\n\n\n <\/figure>\n\n\n\nHere, we\u2019ve opted for a new storage volume of 8GB, classified as a general-purpose gp3 type. It\u2019s crucial to scale up the volume size to align with your needs for production use. Generally, gp3 EBS volumes stand out for their versatility, enhanced burst performance, and potential for cost-effectiveness per gigabyte when compared to gp2 volumes. Your choice between them should hinge on the particular I\/O requirements and performance expectations of your application, as well as any budgetary limits.<\/p>\n\n\n\n
Concluding our setup, we\u2019ll review all the chosen settings in the summary section and then move forward to initiate the instance launch.<\/p>\n\n\n\n <\/figure>\n\n\n\nYou will get the notification that the instance is successfully launched and you can return to your Instances<\/strong> list.<\/p>\n\n\n\n <\/figure>\n\n\n\nAfter a short wait, typically with a fast provisioning time, you’ll be able to locate your instance in the list.<\/p>\n\n\n\n <\/figure>\n\n\n\nThe next step is to connect to the instance via SSH. We can do so by using our Instances<\/strong> menu and clicking Connect<\/strong>:<\/p>\n\n\n\n <\/figure>\n\n\n\nHere we can select the SSH client menu item: <\/p>\n\n\n\n <\/figure>\n\n\n\nNow, we’ll proceed by following the guidance given by AWS to establish a connection with our instance.<\/p>\n\n\n\n
Open your terminal and navigate to the directory where your .pem key file is saved. For security purposes, you need to modify the key’s permissions to ensure it’s not accessible to the public. In this situation, execute the following command:<\/p>\n\n\n\n
\n
chmod 400 jumpcloud_amazon_limux.pem <\/p>\n<\/div><\/div>\n\n\n\n
Next, we will use the SSH key to connect to our instance:<\/p>\n\n\n\n
\n
ssh -i “jumpcloud_amazon_linux.pem” ec2-user@ec2-18-153-64-122.eu-central-1.compute.amazonaws.com<\/p>\n<\/div><\/div>\n\n\n\n
The -i option in SSH lets you define the path to the private key file for authenticating your connection to a remote server. This is especially useful when managing multiple key pairs or when your key files are stored with non-standard names or in different locations.<\/p>\n\n\n\n
Upon your initial login to the Amazon Linux instance, you’ll be prompted to verify the host\u2019s authenticity. In this case, simply type “yes” and hit Enter to proceed.<\/p>\n\n\n\n <\/figure>\n\n\n\nAfter this action, we will be logged into our instance:<\/p>\n\n\n\n <\/figure>\n\n\n\nStep 4: Install Nginx<\/h2>\n\n\n\n First, it is a good idea to fetch the latest updates for our system and we can do so by running the following command:<\/p>\n\n\n\n
\n
sudo dnf update<\/p>\n<\/div><\/div>\n\n\n\n <\/figure>\n\n\n\nAs we can see from the output, there are no new updates since we provisioned a new Amazon Linux instance, but it is always advisable to search for the latest updates.<\/p>\n\n\n\n
Next, we need a Nginx web server for our static website and also for the purposes of reverse proxy for our Node.js application.<\/p>\n\n\n\n