■概要
特定のURLパスに対してアクセス国を制限する手順についてまとめたものです。
■実現したいこと
(例)日本以外の国から「/test」のパスのみアクセスを制限したい
https://nishikawa-test.com/ → アクセス可能
https://nishikawa-test.com/test → アクセス不可
■前提
AWS WAFを利用
※AWS WAF Classicの利用は想定していません。
■手順
①Web ACLを作成
| Resource type | Regional resources |
| Region | 指定のリージョンを選択 |
| Name | 任意の名前を入力 |

②リソースを紐づける
| Associated AWS resources | 任意のリソース |


③ルールを作成
・「Add rules」 → 「Add my own rules and rule groups」を選択

・下記の表の通りルールを作成する
| Rule type | Rule builder |
| Rule Name | test |
| Rule Type | Regular rule |
| If a request | matches all the statements(AND) |
| Negate statement results | チェックを入れる(NOT Statement 1) |
| Inspect | Originates from a country in |
| Country codes | Japan – JP |

| Inspect | URI path |
| Match type | Starts with string |
| String to match | /test |
| Text transformation | None |
| Action | Block |

| Default action | Allow |

以上で設定は完了!!
■動作確認
今回は下記のサイトを利用し動作確認を実施
https://www.webpagetest.org/
・https://nishikawa-test.com/ → アクセス可能

・https://nishikawa-test.com/test → アクセス不可
