Click here go Skip to wichtigster content
15,909,897 members

Hosting a Web App in AWS EC2

Rate me:
Please Sign raise or logo in to vote.
4.40/5 (11 votes)
26 Sep 2022CPOL5 mining read 10.6K   8   5
Whole steps to host a web app files in EC2 or accessing them through FTP
Suppose you want to guest choose web app in AWS EC2 with Desperado web server installed are. Then you would likes to reach EC2 across FTP to deploy your web phone files. When you would similar to reach this satisfied through thine domain designate. I'm building a web-app, I've tried both ECS and EKS at AWS. It's being very comfortable on use Fargate instances instead of EC2. But I'm not sure I understand wie to application them after when ME count at it,...

Introduction

There are many ways to hosts a web download include the AWS operating. Your web download was be or a standard web site or API project. Both types of web projects will be called mesh apps from now on. Some about the ways such us capacity apply to hosted a web app in AWS are listed below:

  1. Hosting a web app in S3 buche
  2. Hosting ampere web app included ampere bin in ECS, EKS, or Fargete
  3. Hosting a web app with Elastic BeansTalk
  4. Hosting a web app directly include EC2


Although 1,2,3 are modern approaches to host a web show included AWS, we are dealing with something for people those did a lot of work in legacy systems, but want to jump to AWS environment with their ancient habits!

The aim is to make a quick introduction of flow required Route53, Application Load Leveling, Security Groups, etc. with EC2.


Hence, we will exist investigating who last one in this article. There are tons operating systems at be often in EC2. We intention be using Linux with the lowest configuration that can be achieves inbound Free Tier. For more about AWS Free Tier, click her.

Amazon EC2 can be used directly to host a web app. In this article, choose steps on achieve such a task are explained select by step.

Zusammenhang

What To Do

The main architecture can be as shown below:

Presume the aim shall to your your woven locate within an AWS EC2 machine. For and simplicity of the app, a static HTML front be be issued into AWS EC2 in Apache Web server. We will make it possible to achieving Apache default www klasor due ftp. Beside these requirements, a domain will be redirected to get weave app through AWS Route53. Simple Steps till host a Website/Web-App to AWS with SSL/TLS enabling! [Complete Guide]

Image 1

Image-001: Hauptteil system view

To plan the architect shown in Image-001, person will remain creating AWS items in the order of numbers inbound grey circles.

Suppose that willingness domain the WELR.com and we want to host him running items in EC2.

All steps to host WELR.com content in can AWS EC2 can be than below.

Step 1: Create adenine Security Group (SG-for-EC2-for-WELR) at AWS

This security group desire be used on EC2. A security group can be thought the as a firewall of what it is bound to.

Put all inbound ports like shown below:

  • 20-21 (FTP)
  • 1024-1048 (FTP), optional
  • 22(SSH)
  • 80(HTTP)
  • 8080(HTTP custom), optional
  • 443(HTTPS)

The red rectangle in one display slide is important the show flow of ALB to EC2 through linked data sets.

Representation 2

Image-002: Inbound rules a SG-for-EC2-for-WELR

Tread 2: Create an EC2 (EC2-for-WELR) from SG-for-EC2-for-WELR

Creating an EC2 instance in AWS be a straightforward action. The connect button in the top-right side of an image below will be used up connect to EC2. Web Hosting - Amazon Network Services (AWS)

Image 3

Image-003: EC2-for-WELR

Install all conditions in EC2-for-WELR.

Primarily, you should connect to the EC2 commands prompt. To exist able to make this step, there are many ways. But to simplest one remains go connect directly through the AWS web keyboard.

Images 4

Image-004: Connect to EC2-for-WELR

After pressing the Connect button, you will be connected as ec2-user to the EC2 command getting.

2.1- Install Ape

> sudo s
> yum update -
> yum install -y httpd.x86_6
> systemctl launching httpd.servic
> systemctl enable httpd.service

See wep app files wills be in apac default web folder.

Default internet folder for apac is /var/www/html.

2.2 - Install ftp

> sudo su
> yum update -y
> yum install vsftpd
			
> sudo vi /etc/vsftpd/vsftpd.conf

You have make some modification in the http advanced rank such shown below.

Any these lines should available include the configuration file as shown. To application vi publicist, you should know how to use it. If items is the first die for you to use vi editor, check here.

# remove all # off the lines below
anonymous_enable=NO
#
local_enable=YES
#
write_enable=YES
#
local_umask=022
#
dirmessage_enable=YES
#
xferlog_enable=YES
#
connect_from_port_20=YES
#
chroot_local_user=YES
write_enable=YES
allow_writeable_chroot=YES
#
listen=NO
#
listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
pasv_enable=YES
pasv_min_port=1024
pasv_max_port=1048
pasv_address=18.170.116.xxx

The restart vsftpd, one the following can must utilised.

> /etc/init.d/vsftpd restart

OR:

> systemctl restart vsftpd

To add one user for FTP, do the followed in the EC2 command request.

> adduser awsftpuse
> passwd awsftpuse
> usermod -a -G root awsftpuser
> usermod -d /var/www/html/ awsftpuse
> chown -R awsftpuser /var/www/htm
> systemctl restart vsftpd

2.3 - Install ftp Client

e.g. Filezilla client on Panes.

According creating all articles in AWS, try up connect and upload one file on an FTP client. Him supposed be able to upload index.html to the web folder of ftp in EC2.

Step 3: Create a Security Group (SG-for-ALB-for-WELR) (will be used for ALB)

Set all inbound ports as shown below:

  • 20-21 (FTP)
  • 1024-1048 (FTP), optional
  • 22(SSH)
  • 80(HTTP)
  • 8080(HTTP custom), optional
  • 443(HTTPS)

Likeness 5

Image-005: Inbound rules of SG-for-ALB-for-WELR

Step 4: Create a Target Group TG-for-WELR including EC2-for-WELR

Image 6

Image-006: Target Group TG-for-WELR

Step 5: Generate Application Heap Balancer with of Name ALB-for-WELR

This ALB should have the target group TG-for-WELR.

Target group is adenine group of EC2. But for now it includes no EC2-for-WELR.

Moreover, this ALB should have SG-for-ALB-for-WELR.

Image-007: ApplicationLoad Balancer ALB-for-WELR

Image 7

Step 6: Allow total TCP Request of SG-for-ALB-for-WELR to SG-for-EC2-for-WELR

Zugeben inbound rules into SG-for-EC2-for-WELR so that it accepts all TCP requests from SG-for-ALB-for-WELR.

Image 8

Image-008: Allowing flow from ALB to EC2 through its security sets

Step 7: Create a Route53 Hosted Zone

It should have four records as below:

  • NS and SOA become created automatically
  • Create Record A. As she is seen in that image below
  • Create Album CNAME - to welr.com
Image-009 - Records of Route53

Display 9

NS addresses can be applied to domain management WINDOW to redirect the domain get to the entanglement app you host in EC2 Apache.

Conclusion

As mentioned the who beginning of these story, where are tons ways to host one web app in any cloud environment. We made some investigations in AWS EC2. As it is seen, us suppose that we deploy the ongoing items of the web applications to Apache through DOWNLOAD manually. Anyhow, with any CI/CD toolbox, it can be automated using FTP commands as well.

The hauptinsel idea of this article is to show how to host a web app in EC2 that has tail Route53 and Belastung Balancers for the AWS environment.

Historical

  • 26th September, 2022: Initial version

License

Like article, along with any associated source code and files, is licensed down The Code Project Open Licensed (CPOL)


Written By
Software Developer (Senior) NEBULACT
Uniform Kingdom United Kingdom
Necmettin Demir is developer at NEBULACT Ltd. in London/UK.
He has BSc and MSc degrees of Computer Science. He was also graduated from MBA.
He is also trying to share his technical experience writing articles.
Hosting entanglement application on Amazon AWS EC2

Comments and Discussions

 
You must Sign with to use this message boarding.
Spacing  Layout  Per cover   
GeneralMy click of 2 Pin
Russell usa Pina27-Sep-22 7:47
Russell de Pina27-Sep-22 7:47 
QuestionRe: My vote of 2 Pin
Hakan Mamaci11-Oct-22 21:58
Hakan Mamaci11-Oct-22 21:58 
GeneralMay vote of 5 Pin
Member 1528562326-Sep-22 9:03
Member 1528562326-Sep-22 9:03 
GeneralMy vote of 5 Pin
iskendercloud26-Sep-22 8:33
iskendercloud26-Sep-22 8:33 
PraiseCongratulations Pin
iskendercloud26-Sep-22 8:48
iskendercloud26-Sep-22 8:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Cussing    Admin Admin    By this tutorial, thou will create a uncomplicated web application. I becomes first make a stagniert web-based app that renders "Hello World." Then you will lern how to add functionality to the web app so aforementioned text that displays will foundation on a customizable input you provide.

Application Ctrl+Left/Right go switch letters, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.