AEM Cloud Service - Random CDN YAML Configurations


Configuring traffic at CDN (Fastly) using yaml gives you flexibility managing redirects (instead of using dispatcher or publish) or other simple usecases like basic authentication. More documentation here 

For setting up CDN configuration, create a file <my-site-project>\config\cdn.yaml in project codebase and point to the folder in cloud manager Config Pipeline





1) Create a client side redirect (301) for redirecting "/" to "/content/my-site/en/us.html"

kind: "CDN"
version: "1"
metadata:
envTypes: [ "rde", "dev", "stage", "prod" ]
data:
redirects:
rules:
- name: mysite-redirect-en-us
when:
allOf:
- reqProperty: domain
like: "*mysite*"
- reqProperty: path
equals: /
action:
type: redirect
status: 301
location: /content/mysite/en/us.html


2) Show basic authentication popup for published site...

kind: "CDN"
version: "1"
metadata:
envTypes: ["dev", "stage", "prod"]
data:
authentication:
authenticators:
- name: eaem-basic-authenticator
type: basic
credentials:
- user: batchone
password: ${{BATCH_ONE_CDN_PASSWORD}}
rules:
- name: eam-basic-auth-rule
when:
allOf:
- { reqProperty: tier, equals: "publish" }
- { reqProperty: path, like: "/*" }
action:
type: authenticate
authenticator: eaem-basic-authenticator


                                                   Set the config variable in Env Configuration (Cloud Manager)




3) To show basic authentication for a specific internal domain eg. https://prod-internal.mysite.com.

kind: "CDN"
version: "1"
metadata:
envTypes: [ "rde", "dev", "stage", "prod" ]
data:
authentication:
authenticators:
- name: wem-basic-authenticator
type: basic
credentials:
- user: batchone
password: ${{BATCH_ONE_CDN_PASSWORD}}
rules:
- name: wem-domain-edge-auth-rule
when:
allOf:
- reqProperty: domain
like: "prod-*"
- reqProperty: tier
equals: "publish"
action:
type: authenticate
authenticator: wem-basic-authenticator


                                                   Set the config variable in Env Configuration (Cloud Manager)



4) 

No comments:

Post a Comment