Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Cloud Deployment & Documentation: Setup Elastic IP #41

Open
Tracked by #30
Exochos opened this issue Feb 28, 2024 · 4 comments
Open
Tracked by #30

Cloud Deployment & Documentation: Setup Elastic IP #41

Exochos opened this issue Feb 28, 2024 · 4 comments
Assignees
Labels

Comments

@Exochos
Copy link

Exochos commented Feb 28, 2024

As a dev I would like to have a static IP, since we are using AWS I need to use elastic IP

@Exochos
Copy link
Author

Exochos commented Mar 3, 2024

Allocate an Elastic IP:

  • Navigate to the Elastic IP for EC2.
  • Allocate a new Elastic IP.

Associate the Elastic IP with the Instance:

  • Associate the allocated Elastic IP with the instance.

    Handle Welcome Screen Issues:
    If encountering a welcome screen when accessing the web server from an unexpected location, update the server block in Nginx.

    Point Domain Name to Instance:
    Go to your domain registrar's website.
    Access the DNS settings for your domain.
    Create an A record pointing to the Elastic IP address allocated for your instance.
    Wait for DNS propagation, which can take up to 48 hours.
    Test accessing your website using the domain name to ensure it resolves to the instance correctly.

Why assign a static IP to your instance?

Consistency and Reliability:
    Ensure your instance can always be reached at the same address, regardless of changes or restarts.
Necessary for Various Applications:
    Hosting websites, running services, or establishing secure connections often require a consistent IP address for reliable access by clients.

To setup an Elastic IP in AWS,
A) Use the search function to navigate to the Elastic IP for EC2
image
Next lets allocate an elastic IP:
image
image
image
image

Next we will assosiate the IP with the instance.
image
image
Why are we getting this welcome screen?
Well cause its coming into the web server from an unexpected location and now we need to update the server block to let Nginx know what we want to do.

@Exochos
Copy link
Author

Exochos commented Mar 3, 2024

image
image
image
image
image

@Exochos
Copy link
Author

Exochos commented Mar 3, 2024

Tada!
image

@Exochos
Copy link
Author

Exochos commented Mar 3, 2024

So the chain looks like this now:
Person Types in name in browser or clicks link: The user enters "Northseattlecollegeevents.com" into their web browser or clicks on a link containing the domain name.

DNS Server resolves: The DNS server is queried to resolve "Northseattlecollegeevents.com" to an IP address. The DNS records for "Northseattlecollegeevents.com" are checked, and the corresponding Elastic IP address (e.g., 44.238.195.106) associated with the EC2 instance is retrieved.

Domain Points to Elastic IP: If DNS settings are properly configured, "Northseattlecollegeevents.com" resolves to the Elastic IP address (e.g., 44.238.195.106) associated with your EC2 instance. This is achieved by setting up an A record in the domain's DNS settings pointing to the Elastic IP address.

Example DNS Record:
A Northseattlecollegeevents.com 44.238.195.106

Request Sent to Instance: The user's web browser sends an HTTP request to the Elastic IP address (44.238.195.106), which reaches your EC2 instance.

Instance Responds: Your EC2 instance, configured with Nginx and PM2 running the Next.js application, receives the request. Nginx, configured with a server block for "Northseattlecollegeevents.com," forwards the request to the PM2 server running the Next.js application.

Example Nginx Server Block:

nginx

server {
listen 80;
server_name Northseattlecollegeevents.com;

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;
}

}

The Next.js application served by PM2 processes the request and generates the appropriate response, which is then sent back through Nginx to the user's web browser.

@taylorpapke taylorpapke moved this from Todo to In Progress in NSC Events Apr 19, 2024
@taylorpapke taylorpapke moved this from In Progress to Backlog in NSC Events Apr 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Status: Backlog
Development

No branches or pull requests

2 participants