Skip to content

Commit 781ef9b

Browse files
authored
Improved we-retail filter and dispatcher-mount script (#17)
* improved we-retail filters * Linking enable* files in dispatcher-mount + dedicated domain name for we-retail * add we-retail to /etc/hosts * Fix: Publish farm not copied properly in dispatcher-mount * allow flushing from localhost
1 parent 5ec9930 commit 781ef9b

File tree

13 files changed

+336
-20
lines changed

13 files changed

+336
-20
lines changed

.gitignore

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
1+
.DS_Store
22
/.idea/
3-
logs/
43
*.iml
5-
.DS_Store
4+
5+
# do not check in files generated by dispatcher-mount
6+
logs/
7+
cache/
8+
**/enabled_vhosts
9+
**/enabled_farms
10+
11+
# do not check in samples
12+
**/conf.d/available_vhosts/weretail.vhost
13+
**/conf.dispatcher.d/filters/weretail_filters.any
14+
**/conf.dispatcher.d/available_farms/weretail_publish_farm.any

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
FROM --platform=$TARGETPLATFORM centos:7
1717

1818
# Install HTTPD
19-
RUN yum -y update && yum -y install httpd mod_ssl procps haproxy iputils tree telnet && yum clean all
19+
RUN yum -y update && yum -y install httpd mod_ssl procps haproxy iputils tree telnet less && yum clean all
2020

2121
# Remove default CentOS config
2222
RUN rm -rf /etc/httpd/conf/* && rm -rf /etc/httpd/conf.d/* && rm -rf /etc/httpd/conf.modules.d/*
@@ -26,6 +26,7 @@ COPY ams/2.6/etc/httpd /etc/httpd
2626
# Setup sample configs
2727
COPY sample/weretail_filters.any /etc/httpd/conf.dispatcher.d/filters/weretail_filters.any
2828
COPY sample/weretail_publish_farm.any /etc/httpd/conf.dispatcher.d/available_farms/100_weretail_publish_farm.any
29+
COPY sample/weretail.vhost /etc/httpd/conf.d/available_vhosts/
2930

3031
# Copy haproxy config
3132
COPY haproxy/haproxy.cfg /etc/haproxy

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
7070
## Testing your AEM installation
7171

7272
The dispatcher maps `publish.docker.local` to the local publisher instance on port 4503.
73-
Run the publisher and navigate to [http://publish.docker.local/content/we-retail/language-masters/en.html](http://publish.docker.local/content/we-retail/language-masters/en.html)
73+
Run the publisher and navigate to [http://we-retail.docker.local/content/we-retail/language-masters/en.html](http://we-retail.docker.local/content/we-retail/language-masters/en.html)
7474

7575
## Adapting your localhost
7676

@@ -90,6 +90,7 @@ The Dispatcher connects to the Author and Publisher through `host.docker.interna
9090
$ cat /etc/hosts | grep docker.local
9191
127.0.0.1 author.docker.local
9292
127.0.0.1 publish.docker.local
93+
127.0.0.1 we-retail.docker.local
9394
127.0.0.1 host.docker.internal
9495
```
9596

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/weretail-publishfarm {
2+
## client headers which should be passed through to the render instances
3+
## (feature supported since dispatcher build 2.6.3.5222)
4+
/clientheaders {
5+
$include "/etc/httpd/conf.dispatcher.d/clientheaders/ams_publish_clientheaders.any"
6+
$include "/etc/httpd/conf.dispatcher.d/clientheaders/ams_common_clientheaders.any"
7+
}
8+
## hostname globbing for farm selection (virtual domain addressing)
9+
/virtualhosts {
10+
we-retail
11+
we-retail.docker.local
12+
}
13+
## the load will be balanced among these render instances
14+
/renders {
15+
$include "/etc/httpd/conf.dispatcher.d/renders/ams_publish_renders.any"
16+
}
17+
## only handle the requests in the following acl. default is 'none'
18+
## the glob pattern is matched against the first request line
19+
/filter {
20+
$include "/etc/httpd/conf.dispatcher.d/filters/weretail_filters.any"
21+
}
22+
## if the package is installed on publishers to generate a list of all content with a vanityurl attached
23+
## this section will auto-allow the items to bypass the normal dispatcher filters
24+
## Reference: https://docs.adobe.com/docs/en/dispatcher/disp-config.html#Enabling%20Access%20to%20Vanity%20URLs%20-%20/vanity_urls
25+
#/vanity_urls {
26+
# /url "/libs/granite/dispatcher/content/vanityUrls.html"
27+
# /file "/tmp/vanity_urls"
28+
# /delay 300
29+
#}
30+
## allow propagation of replication posts (should seldomly be used)
31+
/propagateSyndPost "0"
32+
## the cache is used to store requests from the renders for faster delivery
33+
## for a second time.
34+
/cache {
35+
## The cacheroot must be equal to the document root of the webserver
36+
/docroot "${PUBLISH_DOCROOT}"
37+
## sets the level upto which files named ".stat" will be created in the
38+
## document root of the webserver. when an activation request for some
39+
## handle is received, only files within the same subtree are affected
40+
## by the invalidation.
41+
/statfileslevel "${DEFAULT_STAT_LEVEL}"
42+
## caches also authorized data
43+
/allowAuthorized "0"
44+
## Flag indicating whether the dispatcher should serve stale content if
45+
## no remote server is available.
46+
/serveStaleOnError "1"
47+
## the rules define, which pages should be cached. please note that
48+
## - only GET requests are cached
49+
## - only requests with an extension are cached
50+
## - only requests without query parameters ( ? ) are cached
51+
## - only unauthorized pages are cached unless allowUnauthorized is set to 1
52+
/rules {
53+
$include "/etc/httpd/conf.dispatcher.d/cache/ams_publish_cache.any"
54+
}
55+
# the invalidate section defines those pages which are 'invalidated' after
56+
# any activation. please note that, the activated page itself and all
57+
# related documents are flushed on an modification. for example: if the
58+
# page /foo/bar is activated, all /foo/bar.* files are removed from the
59+
# cache.
60+
/invalidate {
61+
/0000 {
62+
/glob "*"
63+
/type "deny"
64+
}
65+
/0001 {
66+
/glob "*.html"
67+
/type "allow"
68+
}
69+
}
70+
/allowedClients {
71+
## By default block all IP from allowing to initiate the invalidation commands
72+
/0000 {
73+
/glob "*.*.*.*"
74+
/type "deny"
75+
}
76+
## Allow certain IP's like publishers to invalidate cache
77+
$include "/etc/httpd/conf.dispatcher.d/cache/ams_publish_invalidate_allowed.any"
78+
}
79+
## Cache response headers next to a cached file. On the first request to
80+
## an uncached resource, all headers matching one of the values found here
81+
## are stored in a separate file, next to the cache file. On subsequent
82+
## requests to the cached resource, the stored headers are added to the
83+
## response.
84+
## Note, that file globbing characters are not allowed here.
85+
/headers {
86+
"Cache-Control"
87+
"Content-Disposition"
88+
"Content-Type"
89+
"Expires"
90+
"Last-Modified"
91+
"X-Content-Type-Options"
92+
}
93+
## By default we want to cache every page regardless if it has a query parameter.
94+
## For pages that render html differently based on the query parameters
95+
## please add entries to deny the caching of those query parameters in this section
96+
/ignoreUrlParams {
97+
/0001 { /glob "*" /type "allow" }
98+
}
99+
100+
# A grace period defines the number of seconds a stale, auto-invalidated
101+
# resource may still be served from the cache after the last activation
102+
# occurring. Auto-invalidated resources are invalidated by any activation,
103+
# when their path matches the /invalidate section above. This setting
104+
# can be used in a setup, where a batch of activations would otherwise
105+
# repeatedly invalidate the entire cache.
106+
/gracePeriod "2"
107+
108+
## Enable TTL evaluates the response headers from the backend, and if they
109+
## contain a Cache-Control max-age or Expires date, an auxiliary, empty file
110+
## next to the cache file is created, with modification time equal to the
111+
## expiry date. When the cache file is requested past the modification time
112+
## it is automatically re-requested from the backend.
113+
# /enableTTL "1"
114+
}
115+
}

ams/2.6/etc/httpd/conf.dispatcher.d/cache/ams_publish_invalidate_allowed.any

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@
77
/glob "${PUBLISH_IP}"
88
/type "allow"
99
}
10+
/02 {
11+
/glob "127.0.0.1"
12+
/type "allow"
13+
}

dispatcher-kill

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
docker kill dispatcher
3+
docker kill mydispatcher

dispatcher-login

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
docker exec -it dispatcher /bin/bash
3+
docker exec -it mydispatcher /bin/bash

dispatcher-mount

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,41 @@ mkdir cache 2> /dev/null
1818

1919
echo ""
2020
echo "Starting dispatcher, mounting local configuration from ./$VERSION/$PATH_TO_CONF ..."
21-
echo " Open your browser at http://publish.docker.local/content/we-retail/us/en.html
21+
echo " Open your browser at http://publish.docker.local/content/we-retail/us/en.html "
2222
echo " **** Press Ctrl-C to stop **** "
2323
echo ""
2424

25+
# copy sample we-retail files
26+
cp sample/weretail.vhost $VERSION/etc/httpd/conf.d/available_vhosts
27+
cp sample/weretail_publish_farm.any $VERSION/etc/httpd/conf.dispatcher.d/available_farms/100_weretail_publish_farm.any
28+
cp sample/weretail_filters.any $VERSION/etc/httpd/conf.dispatcher.d/filters
29+
30+
#create and link up default enabled vhosts
31+
if [ ! -d $VERSION/etc/httpd/conf.d/enabled_vhosts ]; then
32+
mkdir $VERSION/etc/httpd/conf.d/enabled_vhosts
33+
fi
34+
35+
ln -Fs ../available_vhosts/aem_author.vhost $VERSION/etc/httpd/conf.d/enabled_vhosts/aem_author.vhost
36+
ln -Fs ../available_vhosts/aem_flush_author.vhost $VERSION/etc/httpd/conf.d/enabled_vhosts/aem_flush_author.vhost
37+
ln -Fs ../available_vhosts/aem_publish.vhost $VERSION/etc/httpd/conf.d/enabled_vhosts/aem_publish.vhost
38+
ln -Fs ../available_vhosts/aem_flush.vhost $VERSION/etc/httpd/conf.d/enabled_vhosts/aem_flush.vhost
39+
ln -Fs ../available_vhosts/aem_health.vhost $VERSION/etc/httpd/conf.d/enabled_vhosts/aem_health.vhost
40+
ln -Fs ../available_vhosts/weretail.vhost $VERSION/etc/httpd/conf.d/enabled_vhosts/weretail.vhost
41+
42+
#create and link up default enabled farms
43+
if [ ! -d $VERSION/etc/httpd/conf.dispatcher.d/enabled_farms ]; then
44+
mkdir $VERSION/etc/httpd/conf.dispatcher.d/enabled_farms
45+
fi
46+
ln -Fs ../available_farms/000_ams_catchall_farm.any $VERSION/etc/httpd/conf.dispatcher.d/enabled_farms/000_ams_catchall_farm.any
47+
ln -Fs ../available_farms/001_ams_author_flush_farm.any $VERSION/etc/httpd/conf.dispatcher.d/enabled_farms/001_ams_author_flush_farm.any
48+
ln -Fs ../available_farms/001_ams_publish_flush_farm.any $VERSION/etc/httpd/conf.dispatcher.d/enabled_farms/001_ams_publish_flush_farm.any
49+
ln -Fs ../available_farms/002_ams_author_farm.any $VERSION/etc/httpd/conf.dispatcher.d/enabled_farms/002_ams_author_farm.any
50+
ln -Fs ../available_farms/002_ams_publish_farm.any $VERSION/etc/httpd/conf.dispatcher.d/enabled_farms/002_ams_publish_farm.any
51+
52+
#set up sample configs
53+
ln -Fs ../available_farms/100_weretail_publish_farm.any $VERSION/etc/httpd/conf.dispatcher.d/enabled_farms/100_weretail_publish_farm.any
54+
55+
2556
docker run -p 80:8080 -p 443:8443 -it --rm \
2657
--mount type=bind,src=$(pwd)/$VERSION/$PATH_TO_CONF/conf,dst=/etc/httpd/conf,readonly=true \
2758
--mount type=bind,src=$(pwd)/$VERSION/$PATH_TO_CONF/conf.d,dst=/etc/httpd/conf.d,readonly=true \
@@ -33,4 +64,3 @@ docker run -p 80:8080 -p 443:8443 -it --rm \
3364
--env-file scripts/env.sh \
3465
--name mydispatcher dispatcher | cat
3566

36-

dispatcher-remote

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
docker run -p 80:8080 -p 443:8443 -itd --rm --name dispatcher --env-file scripts/env.sh dispatcher
3+
docker run -p 80:8080 -p 443:8443 -itd --rm --name mydispatcher --env-file scripts/env.sh dispatcher

sample/weretail.vhost

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
## Collect any enviromental variables that are set in /etc/sysconfig/httpd
2+
## Collect the dispatchers number
3+
PassEnv DISP_ID
4+
5+
<VirtualHost *:80>
6+
## allowing slashes in the URL to be encoded and still honored
7+
AllowEncodedSlashes On
8+
ServerName we-retail
9+
## Put names of which domains are used for your published site/content here
10+
ServerAlias we-retail.docker.local
11+
12+
13+
## Use a doc root that matches what's in the /etc/httpd/conf/publish-farm.any
14+
DocumentRoot ${PUBLISH_DOCROOT}
15+
## Add header breadcrumbs for help in troubleshooting
16+
<IfModule mod_headers.c>
17+
Header always add X-Dispatcher ${DISP_ID}
18+
Header always add X-Vhost "publish"
19+
Header merge X-Frame-Options SAMEORIGIN "expr=%{resp:X-Frame-Options}!='SAMEORIGIN'"
20+
Header merge X-Content-Type-Options nosniff "expr=%{resp:X-Content-Type-Options}!='nosniff'"
21+
#### Make sure proxies don't deliver the wrong content
22+
Header append Vary User-Agent env=!dont-vary
23+
## Force SSL for author
24+
## Add HSTS for avoiding man in the middle during browser redirect to SSL
25+
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"
26+
</IfModule>
27+
<Directory />
28+
## Update /etc/sysconfig/httpd with setting the PUBLISH_WHITELIST_ENABLED from 0 or 1 to enable or disable ip restriction rules
29+
<If "${PUBLISH_WHITELIST_ENABLED} == 1">
30+
Include /etc/httpd/conf.d/whitelists/*_whitelist.rules
31+
</If>
32+
<IfModule disp_apache2.c>
33+
## Some items cache with the wrong mime type
34+
## Use this option to use the name to auto-detect mime types when cached improperly
35+
ModMimeUsePathInfo On
36+
## Use this option to avoid cache poisioning
37+
## Sling will return /content/image.jpg as well as /content/image.jpg/ but apache can't search /content/image.jpg/ as a file
38+
## Apache will treat that like a directory. This assures the last slash is never stored in cache
39+
DirectorySlash Off
40+
## Enable the dispatcher file handler for apache to fetch files from AEM
41+
SetHandler dispatcher-handler
42+
</IfModule>
43+
Options FollowSymLinks
44+
AllowOverride None
45+
#### Insert filter
46+
SetOutputFilter DEFLATE
47+
#### Don't compress images
48+
SetEnvIfNoCase Request_URI \
49+
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
50+
</Directory>
51+
<Directory "${PUBLISH_DOCROOT}">
52+
AllowOverride None
53+
Require all granted
54+
</Directory>
55+
<IfModule disp_apache2.c>
56+
## Enabled to allow rewrites to take affect and not be ignored by the dispatcher module
57+
DispatcherUseProcessedURL 1
58+
## Default setting to allow all errors to come from the aem instance
59+
DispatcherPassError 0
60+
</IfModule>
61+
<IfModule mod_rewrite.c>
62+
ReWriteEngine on
63+
LogLevel warn rewrite:info
64+
##Global rewrite include
65+
Include /etc/httpd/conf.d/rewrites/base_rewrite.rules
66+
## Update /etc/sysconfig/httpd with setting the PUBLISH_FORCE_SSL from 0 or 1 to enable or disable enforcing SSL
67+
<If "${PUBLISH_FORCE_SSL} == 1">
68+
Include /etc/httpd/conf.d/rewrites/xforwarded_forcessl_rewrite.rules
69+
</If>
70+
</IfModule>
71+
</VirtualHost>

0 commit comments

Comments
 (0)