Dispatcher SDK: Validate Dispatcher Configuration Locally
Dispatcher configuration is the part of an AEM as a Cloud Service project that fails without telling you. A missing /0001 rule or an allowed path that’s too broad can sail through review, reach a Cloud Manager pipeline, and only break when a real request arrives. The Dispatcher SDK lets you catch those problems on your laptop, where they cost seconds instead of a pipeline run.
In this lesson I’ll show you how to set up the Dispatcher SDK, lay out the mysite Dispatcher configuration in flexible mode, and run validate.sh to check it. Then you’ll run docker_run.sh and test filters and cache rules against real requests.
The names follow the rest of the series: project mysite, program 12345, environment 67890.

Table of contents
- Why this matters
- Who should read this
- Prerequisites
- What the Dispatcher SDK gives you
- The flexible mode folder structure
- What validate.sh checks
- Hands-on: validate and test the mysite Dispatcher locally
- Common mistakes and troubleshooting
- Hands-on challenge
- Key takeaways
- Knowledge check
- Frequently asked questions
- Continue your learning
Why this matters
The Dispatcher sits between the CDN and your publish instances. It decides which requests reach AEM, what gets cached and what gets rejected. If you only test a rule in a deployed environment, you’ll learn about its mistakes from a failed build or a production incident.
✅ Validation takes seconds, and you don’t need a Cloud Manager pipeline.
✅ You can try your filters and cache rules with curl before anything is deployed.
✅ The same checks run on your machine and in the pipeline, so a local pass means a lot.
✅ A broken configuration gets caught before it can block the publish path for every visitor.
Who should read this
- You edit the
dispatcher/srcfolder in an AEM as a Cloud Service project. - You’re a DevOps engineer who wants to catch Dispatcher errors before they reach Cloud Manager.
- You’re an architect looking for a repeatable way to review Dispatcher changes.
Prerequisites
Do Lesson 4, Set Up AEMaaCS Local Development first. It covers downloading and unpacking the Dispatcher SDK and your first validate.sh and docker_run.sh. This lesson goes deeper: the flexible mode layout, what each validation phase catches, and how to write and test filter and cache rules. Lesson 5 explains where the dispatcher folder sits in the project, and the OSGi configs and environment variables guide covers the variables side.
You’ll need Docker Desktop running, a Git-based mysite project with a dispatcher folder, and the Dispatcher SDK from the Software Distribution portal. Still on a Dispatcher 6.x setup? The Dispatcher setup guide (6.x) covers that older layout. This lesson doesn’t.
What the Dispatcher SDK gives you
Lesson 4 showed how to download and unpack the SDK. Here, the part you care about is its bin folder. validate.sh checks a configuration folder against Adobe’s rules, and docker_run.sh starts the Dispatcher in a container so you can send it real requests. There’s also docker_run_hot_reload.sh, which does the same but watches your files and reloads on every change.
The Dispatcher runs in Docker. The validator needs Docker for its syntax check, though the rule checks run without it. Install Docker Desktop and make sure it’s running before you start.
| Tool | What it checks | Needs Docker | Needs AEM running |
|---|---|---|---|
validate.sh, phase 1 | Directives and files against the allowlist of Adobe-approved settings. | No | No |
validate.sh, phase 2 | Apache syntax of the configuration, in a container. | Yes | No |
validate.sh, phase 3 | Immutable files are unchanged from the SDK versions. | No | No |
docker_run.sh | Live behaviour: filters, cache rules, vhosts and rewrites. | Yes | Yes, or a stub on the backend port |
The flexible mode folder structure
Flexible mode is the layout AEM as a Cloud Service projects use today. The older layout crammed almost everything into one large file set and kept the rules in a single rewrite.rules file. Flexible mode lets you split the configuration into named files in subfolders, and it removes the rewrite-rule limit of the older layout. The table compares the two.
| Area | Legacy layout | Flexible mode |
|---|---|---|
| Opt-in | Default before the switch. | Enabled by the opt-in/USE_SOURCES_DIRECTLY file. |
| Rewrite rules | A single rewrite.rules file. | Rewrites in conf.d/rewrites, split across as many files as you need. |
| Filters, cache and renders | Shared files with fixed names. | Any file name in its folder, pulled in with $include. |
| Web tier config pipeline | Not supported. | Supported. Cloud Manager reads the dispatcher/src folder directly. |
Here’s the folder layout for mysite. The folders are fixed, but you pick the file names inside them.
dispatcher/
└── src/
├── conf.d/
│ ├── available_vhosts/
│ │ └── mysite.vhost
│ ├── enabled_vhosts/
│ ├── rewrites/
│ │ └── rewrite.rules
│ └── variables/
│ └── custom.vars
├── conf.dispatcher.d/
│ ├── available_farms/
│ │ └── mysite.farm
│ ├── enabled_farms/
│ ├── cache/
│ │ └── rules.any
│ ├── clientheaders/
│ ├── filters/
│ │ └── filters.any
│ ├── renders/
│ └── virtualhosts/
└── opt-in/
└── USE_SOURCES_DIRECTLY
The enabled_* folders hold symbolic links to the files in available_*. That way you can keep several farms or vhosts on disk and switch one on by changing the link. The opt-in file is an empty marker, and its presence tells the tooling to read the sources directly.
In the variables folder, custom.vars holds your own Apache variables, and global.vars is where you change the Dispatcher and rewrite log levels. On Windows, create the symbolic links with mklink from an elevated prompt, or just use WSL.
Note:- In flexible mode use relative paths. Adobe also requires at least one vhost that matches ServerAlias *.local, localhost and 127.0.0.1 (needed for Dispatcher invalidation), and the aliases *.adobeaemcloud.net and *.adobeaemcloud.com in at least one vhost. Keep the default vhost for these, and add your own beside it.
Note:- Some files in the SDK are immutable. You may edit the ones you own, but changes to the reference defaults fail the phase 3 check described in the next section.
What validate.sh checks
validate.sh runs three phases in order, and a failure in one stops the run. Fix the first error and run it again. Each phase catches a different kind of problem, which is why the table above lists them separately.
- Phase 1, the validator. Every directive in your files must be on the allowlist. You’ll fail here if a directive isn’t on the allowlist, if an allow filter uses
/glob, or if a rule exposes an admin path such as/crx/deor/system/console. Phase 1 does not report Apache syntax or logic problems, so that’s what phase 2 is for. - Phase 2, the syntax check. The configuration is loaded in a Dispatcher container, the same way the real Dispatcher loads it. It picks up Apache syntax errors that the allowlist can’t see.
- Phase 3, the immutability check. Files that Adobe owns must match the SDK version. If you change one, the report names the file.
Note:- The same httpd -t syntax check also runs in the Build Images step of a Cloud Manager deployment, so a phase 2 error you skip locally shows up in the pipeline failure log. See how to read a failed pipeline step.
Hands-on: validate and test the mysite Dispatcher locally
Run each command from the root of the mysite project unless a step says otherwise. Swap ~/dev/aem-sdk-dispatcher for the folder where you unpacked the SDK.
Step 1: Confirm flexible mode is enabled
If your archetype project doesn’t already have the opt-in marker, create it. Then check that your folder structure matches the tree above.
mkdir -p dispatcher/src/opt-in
touch dispatcher/src/opt-in/USE_SOURCES_DIRECTLY
find dispatcher/src -maxdepth 2 -type d | sort

Step 2: Write the farm and filter files
The farm file decides which paths reach AEM. The filter file is your allowlist, so a request that matches no allow rule gets rejected. Keep the admin paths in deny rules, and never allow /crx or /system on publish.
/0001 {
/type "dispatcher"
/renders {
$include "../renders/default_renders.any"
}
/filter {
$include "../filters/filters.any"
}
/virtualhosts {
$include "../virtualhosts/virtualhosts.any"
}
/cache {
/docroot "/mnt/var/www/html"
/rules {
$include "../cache/rules.any"
}
}
}
$include "default_filters.any"
/0100 { /type "allow" /method "GET" /url "/content/mysite/*" /extension "html" }
/0101 { /type "allow" /method "GET" /url "/etc.clientlibs/mysite/*" }
/0102 { /type "allow" /method "GET" /url "/content/dam/mysite/*" }

Link the farm into enabled_farms and the vhost into enabled_vhosts, using relative symbolic links.
cd dispatcher/src/conf.dispatcher.d/enabled_farms
ln -s ../available_farms/mysite.farm mysite.farm
cd ../../conf.d/enabled_vhosts
ln -s ../available_vhosts/mysite.vhost mysite.vhost
cd ../../..
Step 3: Run validate.sh
Point the validator at the dispatcher/src folder. A clean run ends with a success message for every phase. If it doesn’t, read the first error, fix it and run the script again.
~/dev/aem-sdk-dispatcher/bin/validate.sh dispatcher/src

Step 4: Start the Dispatcher with docker_run.sh
Start the Dispatcher the way you did in Lesson 4: against a local publish instance on port 4503, or a stub that returns simple responses. The backend is reached as host.docker.internal. While you’re still editing rules, I’d use the hot-reload script shown after the first command. It watches your files, reloads the Dispatcher and reruns validation on every change, and that saves a lot of time.
~/dev/aem-sdk-dispatcher/bin/docker_run.sh dispatcher/src host.docker.internal:4503 8080
~/dev/aem-sdk-dispatcher/bin/docker_run_hot_reload.sh dispatcher/src host.docker.internal:4503 8080
Two settings help when a rule doesn’t behave. Pass DISP_RUN_MODE to simulate an environment type: the default is dev, and stage or prod load the matching run-mode files. To see why a request was filtered or rewritten, raise DISP_LOG_LEVEL or REWRITE_LOG_LEVEL in conf.d/variables/global.vars. The default is warn, and debug is usually enough.
DISP_RUN_MODE=stage ~/dev/aem-sdk-dispatcher/bin/docker_run.sh dispatcher/src host.docker.internal:4503 8080
Step 5: Test the filters with curl
Send some requests that should pass and some that should fail. The Dispatcher answers a rejected request with a 403, and an allowed request reaches the backend. Run these in a second terminal while the container is running.
# Should be rejected by the default deny rules
curl -i http://localhost:8080/crx/de/index.jsp
curl -i http://localhost:8080/system/console/bundles
# Should reach the backend
curl -i http://localhost:8080/content/mysite/en/home.html

Step 6: Test a cache rule
Cache rules decide what the Dispatcher writes to the docroot. Add a rule that stops the search page from being cached, then check the docroot inside the container. Don’t look on your host, because that’s the wrong place.
$include "default_rules.any"
/0100 { /glob "/content/mysite/en/search*" /type "deny" }
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/content/mysite/en/home.html
CONTAINER=$(docker ps -q | head -n 1)
docker exec "$CONTAINER" ls -R /mnt/var/www/html/content/mysite/en

You should see home.html in the container’s docroot, and search.html shouldn’t show up after you request it. If nothing is cached, check that the response carries cache-friendly headers and that the path matches a rule.
Common mistakes and troubleshooting
Most validation failures come from a short list. The table covers the messages you’re most likely to hit and the fix for each.
| Message or symptom | Cause | Fix |
|---|---|---|
| No farm is loaded, or the farm is ignored | The symbolic link in enabled_farms is missing or points to the wrong file. | Recreate the link with a relative path, and check it with ls -l. |
| An include cannot be resolved | An $include points to a folder or to a file that does not exist. | Point the include at the file, and check the path relative to the file that contains it. |
| Filter must not use glob for allow rules | A /glob pattern appears in an allow rule. | Use /url for allow rules, and keep /glob for deny rules. |
| Non-allowlisted directive | A directive in the vhost or farm is not on the allowlist. | Remove the directive, or use the supported setting for that behaviour. |
| Immutability check failed | A file that Adobe owns was edited. | Restore the file from the SDK version, and move your change into a file you own. |
Requests to /crx or /system succeed | An allow rule is too broad, or the deny rule comes after the allow rule. | Put the deny rules first, and check the allow patterns. |
| Files are not cached | The rule denies the path, or the docroot path in the farm is wrong. | Check the rule order and the /docroot value, then inspect the container. |
| Works in the SDK, fails in Cloud Manager | The local backend returns different headers or paths from the real publish service. | Test with the real publish host, and compare the response headers. |
Web Tier Config pipeline fails with Opt-in file //opt-in/USE_SOURCES_DIRECTLY is not present | The pipeline’s Code Location is /, not the folder that contains the opt-in directory. | Set Code Location to /dispatcher/src for projects from the AEM Project Archetype. |
| Validation reports an exposed admin path | A rule lets /crx/de or /system/console through. | Remove the rule or narrow the allow pattern, then run validate.sh again. |
Hands-on challenge
Extend the mysite configuration to meet the requirements below. Validate after every change, and test each one with curl before you move on.
- Allow
/content/mysite/en/*.htmland deny/content/mysite/en/search*in the cache rules. Confirm it with a request and a docroot check. - Deny
/system/consoleand/crx/*before any allow rule, and confirm each returns 403. - Add a second vhost file named
mysite-stage.vhost, link it intoenabled_vhosts, and confirmvalidate.shstill passes.
Write down the one check you’d add to your pull request template so these checks run for every Dispatcher change.
Key takeaways
- The Dispatcher SDK lets you validate and run Dispatcher configuration on your machine before you deploy.
- Flexible mode uses the
opt-in/USE_SOURCES_DIRECTLYmarker and split configuration files in fixed folders. validate.shruns three phases: the allowlist, the syntax check, and the immutability check.docker_run.shlets you test filters and cache rules with real requests. Remember to check the docroot inside the container.- Put deny rules before allow rules, and test the admin paths with
curlevery time you touch the filters.
Knowledge check
Have a go at each question before you expand the answer.
1. Which file turns on flexible mode for a Dispatcher configuration?
The empty marker file opt-in/USE_SOURCES_DIRECTLY in the dispatcher/src folder.
2. Which validate.sh phase checks that Adobe-owned files are unchanged?
Phase 3, the immutability check.
3. Does phase 1 of validate.sh need Docker to run?
No. Phase 1 checks directives against the allowlist without Docker. Phase 2 needs Docker because it loads the configuration in a container.
4. Why should deny rules for /crx and /system come before the allow rules?
Put the deny rules first. Then a broad allow rule can’t match an admin path before the deny rule gets a chance.
5. What do the three arguments to docker_run.sh specify?
The source folder, the backend host and port, and the local port that the Dispatcher listens on.
Frequently asked questions
Do I need a running AEM instance to run validate.sh?
No. The validator checks the configuration files without an AEM instance. Only docker_run.sh needs a backend, and a stub that returns simple responses is enough for filter and cache tests.
Can I keep the legacy layout?
New projects use flexible mode, and the Cloud Manager web tier config pipeline needs it. If you maintain an older project, move it to flexible mode before you add web tier config pipelines.
Why does validate.sh pass but the site still returns 403?
Validation tells you the configuration is well formed and allowed. It can’t tell you whether your rules match the paths you meant. Use curl against docker_run.sh to confirm what each rule really does.
Should I run validate.sh in CI?
Yes. Run it on every pull request that touches dispatcher/src, so a configuration error fails there and not later in a Cloud Manager pipeline.
Continue your learning
- Previous lesson: Lesson 15, the AEMaaCS config pipeline. See the AEM Cloud roadmap.
- Next lesson: Lesson 17, Dispatcher and CDN Cache Troubleshooting for AEMaaCS.
- Practice quiz: AEM Dispatcher practice test.
- Roadmap: AEM as a Cloud Service learning roadmap.
References
- Validating and Debugging using Dispatcher Tools
- Dispatcher in the Cloud
- Set up local Dispatcher Tools (AEM tutorial)
Leave a Reply