Skip to main content

Restricting access from overseas

info

Estimated time: 5 minutes

Overview

This tutorial explains how to restrict access to a website from overseas using KurocoEdge.
In this exercise, we will be setting up rules in KurocoEdge to restrict the access of the website to only allow traffic from USA or restricting access from specific countries.

Prerequisites

This tutorial assumes that you have completed the following tutorials in the Beginner's Guide.

What You'll Learn

You will learn how to control the display based on the country of origin using the following steps:

Restricting access from countries other than USA

Creating rules

Click on [KurocoEdge] > [Deployment list] in the side menu. Image from Gyazo

Select the draft deployment. Image from Gyazo

Click on [Clone] in the top right corner. Image from Gyazo

As the default backend, set your own site's URL which you added in Changing the Display of Your Website. Image from Gyazo

Click on [Add] in the rule list section. Image from Gyazo

Click on the "Request" tab. Image from Gyazo

Click on [Add Action]. Image from Gyazo

Condition / Variable

Click on [Add Field] under "Condition/Variable" and configure it as follows:

FieldSetting
Field settingsGeolocation
TypeCountryCode
Value patternUS
tip

CountryCode follows the ISO 3166-1 Alpha-2 standard. If you want to set a country code other than Japan, search for "country codes list" on Google or another search engine to find the appropriate code.

Image from Gyazo

Execution

Click on [Add Field] under "Execution" and configure it as follows:

FieldSetting
Field settingsSynthetic response
HTTP status403 Forbidden
BodyEnter the content of the error page in HTML format.
In this tutorial, we have modified the default sample text to "This website cannot be accessed from your country".
HeadersNo editing required

Image from Gyazo

Directive flag

Enable the Invert conditions result settings. Image from Gyazo

Verifying the Rules

Go back to the deployment page and click on [Preview].
Image from Gyazo

When accessing the site from a country other than USA, the display configured in Execution will be shown. Image from Gyazo

Restricting access from specific countries

Creating rules

Click on [KurocoEdge] > [Deployment list] in the side menu. Image from Gyazo

Select the draft deployment. Image from Gyazo

Click on [Clone] in the top right corner. Image from Gyazo

As the default backend, set your own site's URL which you added in Changing the Display of Your Website. Image from Gyazo

Click on [Add] in the rule list section. Image from Gyazo

Click on the "Request" tab. Image from Gyazo

Click on [Add Action]. Image from Gyazo

Condition / Variable

Click on [Add Field] under "Condition/Variable" and configure it as follows:

FieldSetting
Field settingsLocation
TypeCountryCode
Value patternCountry code of the country to restrict access
tip

CountryCode follows the ISO 3166-1 Alpha-2 standard. Search for "country codes list" on Google or another search engine to find the appropriate code.

Image from Gyazo

Execution

Click on [Add Field] under "Execution" and configure it as follows:

FieldSetting
Field settingsSynthetic response
HTTP status403 Forbidden
BodyEnter the content of the error page in HTML format.
In this tutorial, we have modified the default "sample" text to "This website cannot be accessed from your country".
HeadersNo editing required

Image from Gyazo

Verifying the Rules

Go back to the deployment page and click on [Preview].
Image from Gyazo

When accessing the site from the specified country, the screen configured in Execution will be displayed. Image from Gyazo

That's it! You have successfully set up the configuration to block access from overseas.


Support

If you have any other questions, please contact us or check out Our Discord Community.