How to Block Traffic to Your Website from Russia and Belarus by@devabram

How to Block Traffic to Your Website from Russia and Belarus

Read on Terminal Reader
Open TLDR
react to story with heart
react to story with light
react to story with boat
react to story with money
Russia invaded Ukraine on the 24th of February 2022. Our company and I are strong supporters and believers in individual liberty, free trade, and free association. In addition to being against war, we strongly oppose evil and destructive ideas that support autocracies. We want to invite you all to block your website traffic from Russia and Belarus to show support for the Ukrainian people. The following tutorial will help you to enable CloudFront Geographic Restrictions and block traffic.
image
David Abram HackerNoon profile picture

David Abram

I like to build stuff, so I build stuff. Software Developer / Consultant @crocoderdev

youtube social icontwitter social icongithub social iconlinkedin social iconinstagram social icon


Russia invaded Ukraine on the 24th of February 2022. Belarus offers logistic support to the Russian army.


Our company website won't be available in Russia and Belarus until the invasion stops. We don't intend to punish our readers from Russia and Belarus but to show dissatisfaction and disapproval of the political and philosophical stance of the Russian government.


Our company and I are strong supporters and believers in individual liberty, free trade, and free association. In addition to being against war, we strongly oppose evil and destructive ideas that support autocracies. Make no mistake, this is not the doing of one man, but a joint effort of individuals who believe it is not you who should be deciding how to live your life.


We will continue doing as much as possible to show our support for the Ukrainian people and invite you all to do the same. If you use CloudFront as your CDN, the following tutorial will help you to enable CloudFront Geographic Restrictions and block traffic from Russia and Belarus.


If you are using any other CDN or a different provider, send us an email at [email protected]. I will personally assist you in blocking traffic.


I will show you three ways to block traffic depending on how your CloudFront distribution is provisioned.

  • Manually / AWS Console
  • CloudFormation
  • Terraform

Manually / AWS Console

Open CloudFront Distributions and choose the distribution.


CloudFront distribution screen

CloudFront distribution screen


Click on the Geographic restrictions tab. Click on edit button.


CloudFront Geographic restriction tab

CloudFront Geographic restriction tab



Check Restriction type - Block list and select from the dropdown Russia and Belarus. Click Save changes.


Edit geographic restrictions dropdown

Edit geographic restrictions dropdown


You have just blocked all traffic from Russia and Belarus. All visitors from those locations will get 403 (Forrbidden) status code.


CloudFront Geographic restriction tab with blocked traffic from Russia and Belarus

CloudFront Geographic restriction tab with blocked traffic from Russia and Belarus


CloudFormation

If you are deploying the CloudFront via CloudFormation add this code to Restrictions in CloudFrontDistribution Properties.


Use the following code snippet:


CloudFrontDistribution:
  Type: 'AWS::CloudFront::Distribution'
  Properties:
    DistributionConfig:
      ...
      Restrictions:
        GeoRestriction:
          Locations:
          - RU
          - BY
          RestrictionType: blacklist



Terraform

You can easily add restrictions objects to your aws_cloudfront_distributions.


Use the following code snippet:

resource "aws_cloudfront_distribution" "website_distribution" {
  ...
  restrictions {
    geo_restriction {
      restriction_type = "blacklist"
      locations        = ["RU", "BY"]
    }
  }
}


Thank you for reading. ❤️🇺🇦


Also published on CroCoder.

react to story with heart
react to story with light
react to story with boat
react to story with money
David Abram HackerNoon profile picture
by David Abram @devabram.I like to build stuff, so I build stuff. Software Developer / Consultant @crocoderdev
Read my stories

Related Stories

L O A D I N G
. . . comments & more!