Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 9e8ee58

Browse files
author
Lori Krell
committed
Update code sample
1 parent d8d9910 commit 9e8ee58

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

guides/v2.0/cloud/configure/cloud-vcl-custom-snippets.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ The curl command would look like the following:
214214

215215
[Validate and activate](#validate) the version to activate the snippet.
216216

217-
### Create a whitelist VCL {#block-ip}
217+
### Create a whitelist VCL {#whitelist-ip}
218218
You may want to create a whitelist of IPs to allow accessing your Magento Admin console. You can create an Edge ACL list of the whitelisted IPs with a VCL snippet. The code checks the IP of the incoming IP address. If it matches a member of the ACL, it is allowed access. All other IPs receive a 403 Forbidden error.
219219

220220
Of note for this snippet, you want to set the priority to 5 to immediately run and check for whitelisted IPs. This priority runs the snippet immediately and before any of the uploaded and default Magento VCL snippets (magentomodule) that have a priority of 50. The name for the Edge ACL is also `whitelist`. If the domain matches the dictionary, it is allowed access to a path of `/admin`. If you changed your Magento Admin path, use that value in this code example.
@@ -224,13 +224,13 @@ Of note for this snippet, you want to set the priority to 5 to immediately run a
224224
* Priority: 5
225225
* Content:
226226

227-
if (req.url ~ "^/admin" && ! (client.ip ~ whitelist)) {
227+
if ((req.url ~ "^/admin") && !(client.ip ~ whitelist) && !req.http.Fastly-FF) {
228228
error 403 "Forbidden";
229229
}
230230

231231
The curl command would look like the following:
232232

233-
curl -H "Fastly-Key: {FASTLY_API_TOKEN}" -H 'Content-Type: application/json' -H "Accept: application/json" -X POST https://api.fastly.com/service/{Service ID}/version/{Editable Version #}/snippet -d '{"name": "block_bad_ips", "type": "recv", "dynamic": 0, "priority": 5, "content": "if (req.url ~ "^/admin" && ! (client.ip ~ whitelist)) { error 403 "Forbidden"; }"}
233+
curl -H "Fastly-Key: {FASTLY_API_TOKEN}" -H 'Content-Type: application/json' -H "Accept: application/json" -X POST https://api.fastly.com/service/{Service ID}/version/{Editable Version #}/snippet -d '{"name": "block_bad_ips", "type": "recv", "dynamic": 0, "priority": 5, "content": "if ((req.url ~ "^/admin") && !(client.ip ~ whitelist) && !req.http.Fastly-FF) { error 403 "Forbidden"; }"}
234234

235235
[Validate and activate](#validate) the version to activate the snippet.
236236

0 commit comments

Comments
 (0)