🚫3 Ways to Geo-Restrict your App
Tags: cloud, security, productivity, tutorial
Published: 2022-03-08 02:47:14

## DAY 19 -🚫 3 Ways to geo-restrict your App - Day Nineteen
[![Image clicktotweet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2xzqms84df74vxuh4xx.png)![Image Cover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5pcvxop0lm2i0f5oileb.jpg)](https://twitter.com/intent/tweet?text=3%20Ways%20to%20geo-restrict%20your%20App%20-%20a%20blog%20by%20%40anuvindhs%0A%23security%20%23cloud%20%23cdn%20%23waf%0A%0Ahttps%3A%2F%2Fdev.to%2Fanuvindhs%2F3-ways-to-geo-restrict-your-app-1p9e%20)


[100 days of Cloud on GitHub](https://github.com/anuvindhs/100daysofcloud) - [Read On iCTPro.co.nz](https://ictpro.co.nz) - [Read on Dev.to](https://dev.to/anuvindhs)

------
In this tutorial i will show demo of , restricting your application to specific country.



## 📝Prerequsite
Access to your WAF, Cloud Front, Route53 and privileges to manage it



## 🌩️ Using CloudFront

- Login into Console and goto CloudFront 
![Image Cloudfront](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n2mdw76ckhjsyw9derqk.png)
- Select your cloud front Distribution
![Image distribustion](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6w9f7ezcvqdffim1jnqh.png)
 
- Go to **Geographic Restrictions** and select **edit** 
![Image edit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxi7zesqn27wrxgu66dx.png)

- Select **Block list**, and type in the country you want to restrict. and click **Save changes** 
![Image restrict](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nc6uv21s9bbqyhj45ff6.png)
 
## 🛡️ Using WAF & Shield 

- Login to console and go to **WAF & Shield**
![Image waf](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2bt4vq81q1ch683uo6k5.png)
- Select your  **Web ACLs** and go to **Rules**. Then Click **Add my own rules and rule group**
![Image ownrule](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ricuk6rbbmrsgiz42pzi.png)
 
-  Select **Rule Builder** and Name the rule. 
![Image name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yv4t7ywxop2c56rwm2ml.png)
- Select inspect as **Originates from a country in** and type the bad country you want to restrict access.
![Image block country](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dn5c6j5x33ty6d2d2n45.png)
- Then select Action as **Block** then click **Add rule**.
![Image blockrule](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hxa62gue3a94ylxncw9u.png)
 
## 🛣️ Using Route53


 - Here the concept is a bit different rather than blocking them completely , what route53 does is it will redirect traffic from selected country to a diffrent end point which can be an s3 hosted site which says " You don't have access to this website from your country". 
   - Check out this [Tutorial](https://ictpro.co.nz/hosting-static-website-in-s3-how-to/) to see how can you create a website with s3.

-  once you host your site on s3 for the Bad-Country , you can just point it with R53.
 - Login into Console and goto **Route53**.
![Image r53](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bwyb3r4g81hsl4uytpvz.png)
 - Click on to your **Hosted Zones** and select **Traffic policies**.
 - Now clcik and create **Create Traffic Policy**
 - Name the Policy![Image name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dut1l8fla9q44sru7kix.png)
 - Enter information as shown below. and click **Create Traffic Policy** 
![Image map](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eg6r6qomhppf2tb946u1.png)
 - Select your Domain and Click **Create Policy Records**
 ![Image r53policy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/urtfkx2m4al9pr018w6f.png)

**Remember there is $50 charge for this so its recommended to use first two options**


🎉Congratulations🎉 you have successfully blocked access to your app for a unauthorised Country.
 
 
 





 ----------

**✅Connect with me on [Twitter](https://twitter.com/intent/follow?ref_src=anuvindhs&screen_name=anuvindhs)
 🤝🏽Connect with me on [Linkedin](https://www.linkedin.com/in/anuvindhs)
🧑🏼‍🤝‍🧑🏻 Read more post on [dev.to](https://dev.to/anuvindhs) or  [iCTPro.co.nz](https://ictpro.co.nz)
💻 Connect with me on [GitHub](https://github.com/anuvindhs)**


{% user anuvindhs %}