Setting Up an EC2 Server on AWS

Setting Up an EC2 Server on AWS

Step 1: Introduction to AWS

AWS, or Amazon Web Services, provides a vast array of cloud services. Here are some key features:

– Rent Servers: Flexibly rent virtual servers as needed.
– Manage Domains: Handle domain names and DNS settings.
– Upload Objects: Store various types of files including images, videos, and audio files.
– Autoscale Servers: Automatically adjust server capacity based on traffic.
– Create Kubernetes Clusters: Set up and manage Kubernetes clusters for containerized applications.

Step 2: Understanding EC2 Servers

AWS’s virtual machines are known as EC2 servers, which stands for Elastic Compute Cloud. The key features of EC2 include:

– Elastic: Easily scale the size of your machine up or down.
– Compute: Provides computing power as a machine.
– Dashboard Management: You can spin up new EC2 instances directly from the AWS dashboard.

Step 3: Creating a New EC2 Server

To create a new EC2 server, follow these steps:

  1. Click on Launch a New Instance
  2. Give a Name
  3. Select an Operating System (OS)
  4. Select Size
  5. Create a New Key Pair
  6. Select Instance Size Again
  7. Allow Traffic on HTTP/HTTPS

Step 4: SSH into the Server

Once your instance is running, you need to SSH into it. Here’s how:

  1. Give SSH Key Permissions:
    chmod 700 kirat-class.pem
    “`2. SSH into the Machine:
    ssh -i kirat-class.pem
    “`3. Clone the Repository:
    git clone
    “`If you encounter an error about internet access, follow this solution:

    4. Install Node.js:
    Follow this DigitalOcean tutorial:

    5. Install Dependencies:
    cd sum-server
    npm install

    6. Start the Backend:
    node index.js

Step 5: Installing the Repository

To install the repository, clone it using:

git clone

Step 6: Accessing Your Server

After setting up, you can access your EC2 server using its IP or DNS. For example:


If you encounter issues accessing the server, you may need to configure the security group to open the necessary ports.

Step 7: Setting Up Nginx

Nginx is a powerful reverse proxy server. Here’s how to set it up:

  1. Install Nginx:
    sudo apt update
    sudo apt install nginx
    “`This should start the Nginx server on port 80.2. Configure Nginx as a Reverse Proxy:
    Edit the Nginx configuration file:
    sudo vi /etc/nginx/nginx.conf
    Add the following configuration:
    events {
    # Event directives…
    }http {
    server {
    listen 80;

    location / {
    proxy_pass http://localhost:8080;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection ‘upgrade’;
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    Reload Nginx to apply the changes:
    sudo nginx -s reload

    3. Start the Backend Server:
    node index.js

    4. Visit the Website:

Step 8: Certificate Management

To secure your site with HTTPS, use Certbot. Follow the instructions on Certbot’s official site: to set up SSL certificates.


By following these steps, you can set up and manage an EC2 server on AWS, configure it with Nginx as a reverse proxy, and secure it with SSL certificates. AWS EC2 provides a robust and scalable environment for hosting your applications, and with tools like Nginx and Certbot, you can ensure your server is both accessible and secure. Happy hosting!

Leave a Reply

Your email address will not be published. Required fields are marked *