Skip to content

Commit

Permalink
sync dispatcher immutable files with Dispatcher SDK and image v2.0.166
Browse files Browse the repository at this point in the history
  • Loading branch information
krystiannowak committed Feb 20, 2023
1 parent 13ab85c commit f063d78
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 45 deletions.
2 changes: 2 additions & 0 deletions src/main/archetype/dispatcher.cloud/immutable.files
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
src/conf.d/available_vhosts/default.vhost
src/conf.d/dispatcher_vhost.conf
src/conf.d/enabled_vhosts/vhosts.conf
src/conf.d/rewrites/default_rewrite.rules
src/conf.dispatcher.d/available_farms/default.farm
src/conf.dispatcher.d/cache/default_invalidate.any
src/conf.dispatcher.d/cache/default_rules.any
src/conf.dispatcher.d/clientheaders/default_clientheaders.any
src/conf.dispatcher.d/dispatcher.any
src/conf.dispatcher.d/enabled_farms/farms.any
src/conf.dispatcher.d/filters/default_filters.any
src/conf.dispatcher.d/renders/default_renders.any
src/conf.dispatcher.d/virtualhosts/default_virtualhosts.any
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ Include conf.d/variables/custom.vars

# Rewrite index page internally, pass through (PT)
RewriteRule "^(/?)$" "/index.html" [PT]
</IfModule>

# Content Services/Sling Model Exporter: Cache for 5min with background refresh 1h on browser and 12h on CDN to avoid MISS
<LocationMatch "^/content/.*\.model\.json$">
Header set Cache-Control "max-age=300,stale-while-revalidate=3600" "expr=%{REQUEST_STATUS} < 400"
Header set Surrogate-Control "stale-while-revalidate=43200,stale-if-error=43200" "expr=%{REQUEST_STATUS} < 400"
Header set Age 0
</LocationMatch>
</IfModule>
</VirtualHost>
100 changes: 70 additions & 30 deletions src/main/archetype/dispatcher.cloud/src/conf.d/dispatcher_vhost.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Include conf.d/variables/global.vars
# WARNING!!! The probe paths below are INTERNAL and RESERVED - please DO NOT USE them in your virtual host configurations!

# Liveness probe URL
Alias "/system/probes/live" /etc/httpd/probes/live-status.json
Alias "/system/probes/live" probes/live-status.json
# Readiness probe URL
Alias "/system/probes/ready" /etc/httpd/probes/ready-status.json
Alias "/system/probes/ready" probes/ready-status.json
# Startup probe URL
Alias "/system/probes/start" /etc/httpd/probes/startup-status.json
Alias "/system/probes/start" probes/startup-status.json

# internal probes endpoint
<LocationMatch "/system/probes">
Expand Down Expand Up @@ -54,24 +54,6 @@ Alias "/system/probes/start" /etc/httpd/probes/startup-status.json
</LocationMatch>
</IfDefine>

# SITES-5185 - Ensure all GraphQL Queries to production publisher are using Persistent Queries and not direct query requests
<IfDefine ENVIRONMENT_PROD>
SSLProxyEngine on
<LocationMatch "^/content/_cq_graphql/.*/endpoint.json$">
RewriteCond %{ENV:ENABLE_GRAPHQL_ENDPOINT} ^$ [OR]
RewriteCond %{ENV:ENABLE_GRAPHQL_ENDPOINT} ^false$
RewriteRule ^/(.*)$ - [R=404,L]
</LocationMatch>
</IfDefine>
<IfDefine ENVIRONMENT_STAGE>
SSLProxyEngine on
<LocationMatch "^/content/_cq_graphql/.*/endpoint.json$">
RewriteCond %{ENV:ENABLE_GRAPHQL_ENDPOINT} ^$ [OR]
RewriteCond %{ENV:ENABLE_GRAPHQL_ENDPOINT} ^false$
RewriteRule ^/(.*)$ - [R=404,L]
</LocationMatch>
</IfDefine>

# If the module loads correctly then apply base settings for the module
<IfModule disp_apache2.c>
# location of the configuration file. eg: 'conf/dispatcher.any'
Expand Down Expand Up @@ -116,20 +98,23 @@ Alias "/system/probes/start" /etc/httpd/probes/startup-status.json
Header unset Age
</IfDefine>

# SITES-3659 Prevent re-encodes of URLs sent to GraphQL Persisted Queries API endpoint
<LocationMatch "/graphql/execute.json/.*">
ProxyPassMatch http://${AEM_HOST}:${AEM_PORT} nocanon
</LocationMatch>
# SITES-11040 Do ProxyPassMatch, if caching for GraphQL Persisted Queries is not enabled
<IfDefine !CACHE_GRAPHQL_PERSISTED_QUERIES>
# SITES-3659 Prevent re-encodes of URLs sent to GraphQL Persisted Queries API endpoint
<LocationMatch "/graphql/execute.json/.*">
ProxyPassMatch http://${AEM_HOST}:${AEM_PORT} nocanon
</LocationMatch>
</IfDefine>

# (legacy) Allow ingressroute checks through on /systemready (regardless of dispatcher filters)
# Legacy /systemready mapped to new Health probe URL /system/probes/health in AEM
<Location "/systemready">
ProxyPass http://${AEM_HOST}:${AEM_PORT}/systemready
ProxyPass http://${AEM_HOST}:${AEM_PORT}/system/probes/health
RewriteEngine Off
</Location>

# new Health probe URL to legacy /systemready URL mapping
# Allow ingressroute checks through on /system/probes/health (regardless of dispatcher filters)
<Location "/system/probes/health">
ProxyPass http://${AEM_HOST}:${AEM_PORT}/systemready
ProxyPass http://${AEM_HOST}:${AEM_PORT}/system/probes/health
RewriteEngine Off
</Location>

Expand All @@ -154,6 +139,9 @@ Alias "/system/probes/start" /etc/httpd/probes/startup-status.json
ProxyPassMatch ${COMMERCE_ENDPOINT}$2
ProxyPassReverse ${COMMERCE_ENDPOINT}
RewriteEngine Off
# CIF-2971: Experience Platform Connector cookie to header forwarding
SetEnvIfNoCase Cookie "(^| )aep-segments-membership=([^;]*)" AEP_SEGMENTS_MEMBERSHIP=$2
RequestHeader set aep-segments-membership "%{AEP_SEGMENTS_MEMBERSHIP}e" env=AEP_SEGMENTS_MEMBERSHIP
</LocationMatch>
</IfDefine>
<IfDefine COMMERCE_ENDPOINT_2>
Expand All @@ -165,6 +153,8 @@ Alias "/system/probes/start" /etc/httpd/probes/startup-status.json
ProxyPassMatch ${AEM_COMMERCE_ENDPOINT_2}$2
ProxyPassReverse ${AEM_COMMERCE_ENDPOINT_2}
RewriteEngine Off
SetEnvIfNoCase Cookie "(^| )aep-segments-membership=([^;]*)" AEP_SEGMENTS_MEMBERSHIP=$2
RequestHeader set aep-segments-membership "%{AEP_SEGMENTS_MEMBERSHIP}e" env=AEP_SEGMENTS_MEMBERSHIP
</LocationMatch>
</IfDefine>
<IfDefine COMMERCE_ENDPOINT_3>
Expand All @@ -176,6 +166,8 @@ Alias "/system/probes/start" /etc/httpd/probes/startup-status.json
ProxyPassMatch ${AEM_COMMERCE_ENDPOINT_3}$2
ProxyPassReverse ${AEM_COMMERCE_ENDPOINT_3}
RewriteEngine Off
SetEnvIfNoCase Cookie "(^| )aep-segments-membership=([^;]*)" AEP_SEGMENTS_MEMBERSHIP=$2
RequestHeader set aep-segments-membership "%{AEP_SEGMENTS_MEMBERSHIP}e" env=AEP_SEGMENTS_MEMBERSHIP
</LocationMatch>
</IfDefine>
<IfDefine COMMERCE_ENDPOINT_4>
Expand All @@ -187,6 +179,8 @@ Alias "/system/probes/start" /etc/httpd/probes/startup-status.json
ProxyPassMatch ${AEM_COMMERCE_ENDPOINT_4}$2
ProxyPassReverse ${AEM_COMMERCE_ENDPOINT_4}
RewriteEngine Off
SetEnvIfNoCase Cookie "(^| )aep-segments-membership=([^;]*)" AEP_SEGMENTS_MEMBERSHIP=$2
RequestHeader set aep-segments-membership "%{AEP_SEGMENTS_MEMBERSHIP}e" env=AEP_SEGMENTS_MEMBERSHIP
</LocationMatch>
</IfDefine>
<IfDefine COMMERCE_ENDPOINT_5>
Expand All @@ -198,6 +192,8 @@ Alias "/system/probes/start" /etc/httpd/probes/startup-status.json
ProxyPassMatch ${AEM_COMMERCE_ENDPOINT_5}$2
ProxyPassReverse ${AEM_COMMERCE_ENDPOINT_5}
RewriteEngine Off
SetEnvIfNoCase Cookie "(^| )aep-segments-membership=([^;]*)" AEP_SEGMENTS_MEMBERSHIP=$2
RequestHeader set aep-segments-membership "%{AEP_SEGMENTS_MEMBERSHIP}e" env=AEP_SEGMENTS_MEMBERSHIP
</LocationMatch>
</IfDefine>

Expand All @@ -215,7 +211,7 @@ Alias "/system/probes/start" /etc/httpd/probes/startup-status.json
</Directory>

# internal metadata endpoint
Alias "/gitinit-status" /etc/httpd/metadata/gitinit-status.json
Alias "/gitinit-status" metadata/gitinit-status.json

<LocationMatch "/gitinit-status">
RewriteEngine Off
Expand All @@ -227,6 +223,50 @@ Alias "/gitinit-status" /etc/httpd/metadata/gitinit-status.json
Require expr "%{HTTP_HOST} == '${POD_NAME}'"
</Directory>

# Dedicated vhost for EaaS:
# (currently disabled, but customers can expect it to be enabled in future versions - CQ-4349728)
#<VirtualHost *:80>
# ServerName "test.eaas"
# # possibility to make overrides before directives in this vhost
# IncludeOptional conf.d/includes/first-listed-vhost.pre.includes
# # since this vhost is first-listed one, this setting influences other vhosts - see https://httpd.apache.org/docs/2.4/mod/core.html#limitrequestfieldsize
# LimitRequestFieldSize 32768
# DocumentRoot /var/www/localhost/htdocs
# AllowEncodedSlashes NoDecode
# <IfModule mod_headers.c>
# Header add X-Vhost "test.eaas"
# </IfModule>
# <Directory "/var/www/localhost/htdocs">
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
# </Directory>
#
# # SKYOPS-49434: Allow EaaS to access publish instance directly for dev and stage environments when test.eaas vhost is requested
# <IfDefine ENVIRONMENT_DEV>
# <LocationMatch "/">
# ProxyPassMatch http://${AEM_HOST}:${AEM_PORT}
# RewriteEngine Off
# </LocationMatch>
# </IfDefine>
# <IfDefine ENVIRONMENT_STAGE>
# <LocationMatch "/">
# ProxyPassMatch http://${AEM_HOST}:${AEM_PORT}
# RewriteEngine Off
# </LocationMatch>
# </IfDefine>
# # 403 Forbidden on prod
# <IfDefine ENVIRONMENT_PROD>
# <IfModule mod_rewrite.c>
# RewriteEngine on
# RewriteRule ^ - [F]
# </IfModule>
# </IfDefine>
# # possibility to make overrides after directives in this vhost
# IncludeOptional conf.d/includes/first-listed-vhost.post.includes
#</VirtualHost>

# Customer's vhosts:
Include conf.d/enabled_vhosts/*.vhost

# Create a catch-all vhost
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ RewriteRule .* - [F]
# Block wp-login
RewriteRule ^.*wp-login - [F,NC,L]

# Allow caching of persisted queries
# Allow the dispatcher to be able to cache persisted queries - they need an extension for the cache file
RewriteCond %{REQUEST_URI} ^/graphql/execute.json
RewriteRule ^/(.*)$ /$1;.json [PT,L]
RewriteRule ^/(.*)$ /$1;.json [PT]
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@
#
# Define REWRITE_LOG_LEVEL Warn


# Disable default caching headers
#
# The following headers are set by default dispatcher configuration Expires, Cache-Control, Age.
# If you uncomment and define DISABLE_DEFAULT_CACHING variable these headers are not set any more
# and you can fully customize the caching behavior.
#
# Define DISABLE_DEFAULT_CACHING

# Enable caching for GraphQL persisted queries
#
# By default, GraphQL persisted query responses are not cached in dispatcher.
# If you uncomment and define CACHE_GRAPHQL_PERSISTED_QUERIES variable, then persisted query results
# will be cached in dispatcher. Using CORS, in that case, will require additional dispatcher configuration.
#
# Define CACHE_GRAPHQL_PERSISTED_QUERIES
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@
# well as general marketing related parameters such as e.g. utm_campaign.
# Marketing parameters can normally be ignored on most websites as they are tracked
# through different means.
/ignoreUrlParams {
/0001 { /glob "*" /type "deny" }
# /ignoreUrlParams {
# /0001 { /glob "*" /type "deny" }
# /0002 { /glob "q" /type "allow" }
# $include "../cache/marketing_query_parameters.any"
}
# $include "../cache/marketing_query_parameters.any"
# }

# Cache response headers next to a cached file. On the first request to
# an uncached resource, all headers matching one of the values found here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@
/0061 { /type "allow" /method '(GET|POST|OPTIONS)' /url "/graphql/execute.json*" }

# Allow Forms Document Services requests
/0062 { /type "allow" /method "POST" /url "/adobe/forms/*" }
/0062 { /type "allow" /method '(GET|POST)' /url "/adobe/forms/*" }
30 changes: 30 additions & 0 deletions src/main/resources/META-INF/maven/archetype-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,43 @@
<include>assembly.xml</include>
<include>update_sdk.sh</include>
</includes>
<!-- Exclude dispatcher config immutable files from filtering -->
<excludes>
<exclude>**/conf.d/available_vhosts/default.vhost</exclude>
<exclude>**/conf.d/dispatcher_vhost.conf</exclude>
<exclude>**/conf.d/enabled_vhosts/vhosts.conf</exclude>
<exclude>**/conf.d/rewrites/default_rewrite.rules</exclude>
<exclude>**/conf.dispatcher.d/available_farms/default.farm</exclude>
<exclude>**/conf.dispatcher.d/cache/default_invalidate.any</exclude>
<exclude>**/conf.dispatcher.d/cache/default_rules.any</exclude>
<exclude>**/conf.dispatcher.d/clientheaders/default_clientheaders.any</exclude>
<exclude>**/conf.dispatcher.d/dispatcher.any</exclude>
<exclude>**/conf.dispatcher.d/enabled_farms/farms.any</exclude>
<exclude>**/conf.dispatcher.d/filters/default_filters.any</exclude>
<exclude>**/conf.dispatcher.d/renders/default_renders.any</exclude>
<exclude>**/conf.dispatcher.d/virtualhosts/default_virtualhosts.any</exclude>
</excludes>
</fileSet>
<fileSet filtered="false" packaged="false" encoding="UTF-8">
<directory></directory>
<includes>
<include>**/README*</include>
<include>immutable.files</include>
<include>**/opt-in/**</include>
<!-- Include dispatcher config immutable files as non-filtered ones -->
<include>**/conf.d/available_vhosts/default.vhost</include>
<include>**/conf.d/dispatcher_vhost.conf</include>
<include>**/conf.d/enabled_vhosts/vhosts.conf</include>
<include>**/conf.d/rewrites/default_rewrite.rules</include>
<include>**/conf.dispatcher.d/available_farms/default.farm</include>
<include>**/conf.dispatcher.d/cache/default_invalidate.any</include>
<include>**/conf.dispatcher.d/cache/default_rules.any</include>
<include>**/conf.dispatcher.d/clientheaders/default_clientheaders.any</include>
<include>**/conf.dispatcher.d/dispatcher.any</include>
<include>**/conf.dispatcher.d/enabled_farms/farms.any</include>
<include>**/conf.dispatcher.d/filters/default_filters.any</include>
<include>**/conf.dispatcher.d/renders/default_renders.any</include>
<include>**/conf.dispatcher.d/virtualhosts/default_virtualhosts.any</include>
</includes>
</fileSet>
</fileSets>
Expand Down

0 comments on commit f063d78

Please sign in to comment.