Hosting my website for zero dollar
I’ve been serverless evngalist since the start of a new chapter in form of my company Datavizz. As a startup you face a lot of challanges which you need to survive on. One of those challanges and something that we do very first is to find a web-hosting company who could give us the best rates to host our websites. Well, Why do you want to pay, when you can host your website for free???
Let me show you how I’ve been running my website with
0$ for last two years.
My choice of platform is
[AWS](http://aws.amazon.com/) to run my
Create a S3 Bucket
- Sign in to the AWS Management Console and open the Amazon S3 console
Choose Create bucket
The Create bucket wizard opens to the Name and region page.
- In Bucket name, enter a DNS-compliant name for your bucket.
The bucket name must:
- Be unique across all of Amazon S3.
- Be between 3 and 63 characters long.
- Be without uppercase characters.
- Start with a lowercase letter or number
- In Region, choose the AWS Region where you want the bucket to reside.
- Choose Create
Note: You can also use aws cli to create a s3 bucket
aws s3api create-bucket --bucket my-bucket --region us-east-1
Enable static website hosting
- Choose Properties.
- Choose Static website hosting.
- Choose Use this bucket to host a website.
- Enter the name of your index document. The index document name is typically index.html.
- sample html file
<!DOCTYPE html> <html> <body> <h1>Static Hosting on S3</h1> <p>This site is hosted on s3 bucket</p> </body> </html>
- Upload static files to s3
aws s3 cp index.html s3://mybucket/index.html
- Edit Block Public Access Settings
- Go to block public access settings of your s3 bucket
- Clear Block all public access, and choose Save.
- In the confirmation box, enter confirm, and then choose Confirm.
- Choose the bucket that you have configured as a static website.
Now, This should be enough if you want to host a website for your development usage or a personal website.
But if you are running a production grade website, I would recommend to setup
CloudFront as a CDN for your website which would further optmise the website.
Setting up your Cloudfront Distribution
- Search for
Cloudfrontservice from your AWS Console
- Click on
- Since we are using
Webwe would be clicking on
Get Startedalong that option.
- Select your S3 Bucket as
- If you have your
index.htmlin the root directory of your S3 bucket you can ignore putting information in
- In Cache Settings you can keep things as default.
- Let’s go into
Price Classvery wisely, because it would be the reason of the major cost in your CDN distribution
- Chose AWS WAF if you’ve setup something in it.
- CNAMEs - This is the main configuration in which you need to put your domain name which would be authorised to be served whenever a user tries to request for your website.
- You would also have to setup a SSL certificate for your CNAME. - You could follow that here
- Default Root Object you can specify as
index.htmlif you are using the same.
- Then hit
Create Distributionwhich would help you to get your cloudfron setup done.
Once the Cloudfront status turns
Deployed and state as
Enabled, It means that your Cloudfront distribution is ready to be used.
You can find
Domain Name in your cloudfront distribution which would basically become your URL on which you would have to redirect your traffic coming from your domain.
That’s all and my serverless website setup was ready.
Don’t forget to leave down your review and do give me your comments on what you would like to see next!