Apache Solr open-source search software
SOLR-11752: Support Accept-Encoding header to enable response gzip compression (#281)
Houston Putmanc6d95666b788
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex da261119394..c8a08bb9aa8 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -402,6 +402,9 @@ Improvements* SOLR-15609: Upgrade log4j to 2.14.1 (hossman)+* SOLR-11752: Support "Accept-Encoding" header to enable response gzip compression+ (Matthew Sporleder, Houston Putman, Shawn Heisey, Jan Høydahl)+Optimizations---------------------* SOLR-15433: Replace transient core cache LRU by Caffeine cache. (Bruno Roustant)diff --git a/solr/bin/solr b/solr/bin/solrindex be84209fdf5..d861d4c5845 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -280,6 +280,11 @@ if [ "$SOLR_REQUESTLOG_ENABLED" == "true" ]; thenSOLR_JETTY_CONFIG+=("--module=requestlog")fi+# Jetty gzip module enabled by default+if [ "${SOLR_GZIP_ENABLED:-true}" == "true" ]; then+ SOLR_JETTY_CONFIG+=("--module=gzip")+fi+# Authentication optionsif [ -z "$SOLR_AUTH_TYPE" ] && [ -n "$SOLR_AUTHENTICATION_OPTS" ]; thenecho "WARNING: SOLR_AUTHENTICATION_OPTS environment variable configured without associated SOLR_AUTH_TYPE variable"diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmdindex 5dd67db38b0..b035402296d 100755--- a/solr/bin/solr.cmd+++ b/solr/bin/solr.cmd@@ -159,6 +159,14 @@ IF "%SOLR_REQUESTLOG_ENABLED%"=="true" (set "SOLR_JETTY_CONFIG=!SOLR_JETTY_CONFIG! --module=requestlog")+REM Jetty gzip module enabled by default+IF NOT DEFINED SOLR_GZIP_ENABLED (+ set "SOLR_GZIP_ENABLED=true"+)+IF "%SOLR_GZIP_ENABLED%"=="true" (+ set "SOLR_JETTY_CONFIG=!SOLR_JETTY_CONFIG! --module=gzip"+)+REM Authentication optionsIF NOT DEFINED SOLR_AUTH_TYPE (diff --git a/solr/bin/solr.in.cmd b/solr/bin/solr.in.cmdindex 5ce8b339152..914880bcaa3 100755--- a/solr/bin/solr.in.cmd+++ b/solr/bin/solr.in.cmd@@ -183,6 +183,9 @@ REM -DzkDigestUsername=admin-user -DzkDigestPassword=CHANGEME-ADMIN-PASSWORD ^REM -DzkDigestReadonlyUsername=readonly-user -DzkDigestReadonlyPassword=CHANGEME-READONLY-PASSWORDREM set SOLR_OPTS=%SOLR_OPTS% %SOLR_ZK_CREDS_AND_ACLS%+REM Jetty GZIP module enabled by default+REM set SOLR_GZIP_ENABLED=true+REM When running Solr in non-cloud mode and if planning to do distributed search (using the "shards" parameter), theREM list of hosts needs to be defined in an allow-list or Solr will forbid the request. The allow-list can be configuredREM in solr.xml, or if you are using the OOTB solr.xml, can be specified using the system property "solr.allowUrls".diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.shindex 17b9dc16edb..29760424aa0 100644--- a/solr/bin/solr.in.sh+++ b/solr/bin/solr.in.sh@@ -207,6 +207,8 @@# -DzkDigestReadonlyUsername=readonly-user -DzkDigestReadonlyPassword=CHANGEME-READONLY-PASSWORD"#SOLR_OPTS="$SOLR_OPTS $SOLR_ZK_CREDS_AND_ACLS"+# Jetty GZIP module enabled by default+#SOLR_GZIP_ENABLED=true# Settings for common system values that may cause operational imparement when system defaults are used.# Solr can use many processes and many file handles. On modern operating systems the savings by leavingdiff --git a/solr/server/etc/jetty-gzip.xml b/solr/server/etc/jetty-gzip.xmlnew file mode 100644index 00000000000..cb69edd9f6b--- /dev/null+++ b/solr/server/etc/jetty-gzip.xml@@ -0,0 +1,32 @@+<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">++<!-- =============================================================== -->+<!-- Mixin the GZIP Handler -->+<!-- This applies the GZIP Handler to the entire server -->+<!-- If a GZIP handler is required for an individual context, then -->+<!-- use a context XML (see test.xml example in distribution) -->+<!-- =============================================================== -->++<Configure id="Server" class="org.eclipse.jetty.server.Server">+ <Call name="insertHandler">+ <Arg>+ <New id="GzipHandler" class="org.eclipse.jetty.server.handler.gzip.GzipHandler">+ <Set name="minGzipSize"><Property name="jetty.gzip.minGzipSize" deprecated="gzip.minGzipSize" default="2048"/></Set>+ <Set name="checkGzExists"><Property name="jetty.gzip.checkGzExists" deprecated="gzip.checkGzExists" default="false"/></Set>+ <Set name="compressionLevel"><Property name="jetty.gzip.compressionLevel" deprecated="gzip.compressionLevel" default="-1"/></Set>+ <Set name="inflateBufferSize"><Property name="jetty.gzip.inflateBufferSize" default="0"/></Set>+ <Set name="deflaterPoolCapacity"><Property name="jetty.gzip.deflaterPoolCapacity" default="-1"/></Set>+ <Set name="syncFlush"><Property name="jetty.gzip.syncFlush" default="false" /></Set>++ <Set name="excludedAgentPatterns">+ <Array type="String">+ <Item><Property name="jetty.gzip.excludedUserAgent" deprecated="gzip.excludedUserAgent" default=".*MSIE.6\.0.*"/></Item>+ </Array>+ </Set>++ <Set name="includedMethodList"><Property name="jetty.gzip.includedMethodList" default="GET,POST" /></Set>+ <Set name="excludedMethodList"><Property name="jetty.gzip.excludedMethodList" default="" /></Set>+ </New>+ </Arg>+ </Call>+</Configure>diff --git a/solr/server/modules/gzip.mod b/solr/server/modules/gzip.modnew file mode 100644index 00000000000..3542a45fda0--- /dev/null+++ b/solr/server/modules/gzip.mod@@ -0,0 +1,12 @@+[description]+Enable GzipHandler for dynamic gzip compression+for the entire server.++[tags]+handler++[depend]+server++[xml]+etc/jetty-gzip.xml