Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Modifying maxFormContentSize in Apache Solr service.

Hi Simone,

PFA the jetty.xml file as requested.

Best Regards,

Kaushal

On Thu, Oct 13, 2022 at 12:01 AM Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
Jetty 9.4.x is now at End of Communnity Support

This is a question better suited for solr.

Jetty 9.4.44 is subject to several security vulnerabilities now.
You should upgrade.

Note that your error is not from your effort to set the maxFormContentSize, it's from a different block in your code related to setting the threadpool.

o.e.j.x.XmlConfiguration Config error at <Arg name="threadpool">
    <New id="threadpool" class="com.codahale.metrics.jetty9.InstrumentedQueuedThreadPool"><Arg name="registry">
        <Call id="solrJettyMetricRegistry" name="getOrCreate" class="com.codahale.metrics.SharedMetricRegistries"><Arg>solr.jetty</Arg></Call>
      </Arg></New>
  </Arg>

Traditionally, the `org.eclipse.jetty.server.Request.maxFormContentSize` value is set on the `WebAppContext` or the `ServletContextHandler`, not the `Server`.
The `jetty.xml` doesn't usually contain configuration for a context.

Joakim Erdfelt / joakim@xxxxxxxxxxx


On Wed, Oct 12, 2022 at 11:02 AM Kaushal Shriyan <kaushalshriyan@xxxxxxxxx> wrote:
Hi,

I am running Apache Solr 8.11.2 on CentOS Linux release 7.9.2009 (Core) trying to modify /opt/solr/server/etc/jetty.xml to set the Attribute maxFormContentSize as per the below path

[root@etc]# ls -l
total 76
-rw-r--r-- 1 root root  1950 May 13 03:21 jetty-gzip.xml
-rw-r--r-- 1 root root  3630 May 13 03:21 jetty-https8.xml
-rw-r--r-- 1 root root  3698 Oct 12 17:54 jetty-https.xml
-rw-r--r-- 1 root root  2686 Oct 12 17:53 jetty-http.xml
-rw-r--r-- 1 root root  1850 May 13 03:21 jetty-requestlog.xml
-rw-r--r-- 1 root root  2248 May 13 03:21 jetty-ssl.xml
-rw-r--r-- 1 root root 11646 Oct 12 17:51 jetty.xml
-rw-r--r-- 1 root root 11823 May 13 03:21 security.policy
-rw-r--r-- 1 root root  1279 May 13 03:21 security.properties
-rw-r--r-- 1 root root 24426 May 13 03:21 webdefault.xml
[root@etc]#

I am adding the below attribute in /opt/solr/server/etc/jetty.xml to increase maxFormContentSize

<Call name="setAttribute">
      <Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
      <Arg>1500000</Arg>
</Call>

When i restart the solr service it fails with the below message. 

[root@etc]# service solr restart
Sending stop command to Solr running on port 8983 ... waiting up to 180 seconds to allow Jetty process 4311 to stop gracefully.
Waiting up to 180 seconds to see Solr running on port 8983 [\]  Still not seeing Solr listening on 8983 after 180 seconds!
2022-10-12 10:28:25.469 INFO  (main) [   ] o.e.j.u.log Logging initialized @2083ms to org.eclipse.jetty.util.log.Slf4jLog
2022-10-12 10:28:25.601 WARN  (main) [   ] o.e.j.x.XmlConfiguration Config error at <Arg name="threadpool">
    <New id="threadpool" class="com.codahale.metrics.jetty9.InstrumentedQueuedThreadPool"><Arg name="registry">
        <Call id="solrJettyMetricRegistry" name="getOrCreate" class="com.codahale.metrics.SharedMetricRegistries"><Arg>solr.jetty</Arg></Call>
      </Arg></New>
  </Arg>
2022-10-12 10:28:25.601 WARN  (main) [   ] o.e.j.x.XmlConfiguration  => java.lang.IllegalStateException: Element 'Arg' not skipped
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:507)
java.lang.IllegalStateException: Element 'Arg' not skipped
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:507) ~[jetty-xml-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:468) ~[jetty-xml-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:380) ~[jetty-xml-9.4.44.v20210927.jar:9.4.44.v20210927]
at org.eclipse.jetty.xml.XmlConfiguration.lambda$main$3(XmlConfiguration.java:1893) ~[jetty-xml-9.4.44.v20210927.jar:9.4.44.v20210927]
at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1857) ~[jetty-xml-9.4.44.v20210927.jar:9.4.44.v20210927]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.eclipse.jetty.start.Main.invokeMain(Main.java:218) ~[start.jar:9.4.44.v20210927]
at org.eclipse.jetty.start.Main.start(Main.java:491) ~[start.jar:9.4.44.v20210927]
at org.eclipse.jetty.start.Main.main(Main.java:77) ~[start.jar:9.4.44.v20210927]
[root@etc]#

Am I missing anything? Please guide me to modify maxFormContentSize in solr service. Thanks in advance.

Best Regards,

Kaushal
ReplyForward
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd";>

<!-- =============================================================== -->
<!-- Configure the Jetty Server                                      -->
<!--                                                                 -->
<!-- Documentation of this file format can be found at:              -->
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax        -->
<!--                                                                 -->
<!-- =============================================================== -->


<Configure id="Server" class="org.eclipse.jetty.server.Server">
 <Call name="setAttribute">
      <Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
      <Arg>1500000</Arg>
</Call>

  <!-- =========================================================== -->
  <!-- Configure the Server Thread Pool.                           -->
  <!-- The server holds a common thread pool which is used by      -->
  <!-- default as the executor used by all connectors and servlet  -->
  <!-- dispatches.                                                 -->
  <!--                                                             -->
  <!-- Configuring a fixed thread pool is vital to controlling the -->
  <!-- maximal memory footprint of the server and is a key tuning  -->
  <!-- parameter for tuning.  In an application that rarely blocks -->
  <!-- then maximal threads may be close to the number of 5*CPUs.  -->
  <!-- In an application that frequently blocks, then maximal      -->
  <!-- threads should be set as high as possible given the memory  -->
  <!-- available.                                                  -->
  <!--                                                             -->
  <!-- Consult the javadoc of o.e.j.util.thread.QueuedThreadPool   -->
  <!-- for all configuration that may be set here.                 -->
  <!-- =========================================================== -->
  <Arg name="threadpool">
    <New id="threadpool" class="com.codahale.metrics.jetty9.InstrumentedQueuedThreadPool">
      <Arg name="registry">
        <Call id="solrJettyMetricRegistry" name="getOrCreate" class="com.codahale.metrics.SharedMetricRegistries">
          <Arg>solr.jetty</Arg>
        </Call>
      </Arg>
    </New>
  </Arg>

  <Get name="ThreadPool">
    <Set name="minThreads" type="int"><Property name="solr.jetty.threads.min" default="10"/></Set>
    <Set name="maxThreads" type="int"><Property name="solr.jetty.threads.max" default="10000"/></Set>
    <Set name="idleTimeout" type="int"><Property name="solr.jetty.threads.idle.timeout" default="120000"/></Set>
    <Set name="stopTimeout" type="int"><Property name="solr.jetty.threads.stop.timeout" default="60000"/></Set>
    <Set name="detailedDump">false</Set>
  </Get>


  <!-- =========================================================== -->
  <!-- Http Configuration.                                         -->
  <!-- This is a common configuration instance used by all         -->
  <!-- connectors that can carry HTTP semantics (HTTP, HTTPS, SPDY)-->
  <!-- It configures the non wire protocol aspects of the HTTP     -->
  <!-- semantic.                                                   -->
  <!--                                                             -->
  <!-- This configuration is only defined here and is used by      -->
  <!-- reference from the jetty-http.xml, jetty-https.xml and      -->
  <!-- jetty-spdy.xml configuration files which instantiate the    -->
  <!-- connectors.                                                 -->
  <!--                                                             -->
  <!-- Consult the javadoc of o.e.j.server.HttpConfiguration       -->
  <!-- for all configuration that may be set here.                 -->
  <!-- =========================================================== -->
  <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
    <Set name="secureScheme">https</Set>
    <Set name="securePort"><Property name="solr.jetty.secure.port" default="8443" /></Set>
    <Set name="outputBufferSize"><Property name="solr.jetty.output.buffer.size" default="32768" /></Set>
    <Set name="outputAggregationSize"><Property name="solr.jetty.output.aggregation.size" default="8192" /></Set>
    <Set name="requestHeaderSize"><Property name="solr.jetty.request.header.size" default="8192" /></Set>
    <Set name="responseHeaderSize"><Property name="solr.jetty.response.header.size" default="8192" /></Set>
    <Set name="sendServerVersion"><Property name="solr.jetty.send.server.version" default="false" /></Set>
    <Set name="sendDateHeader"><Property name="solr.jetty.send.date.header" default="false" /></Set>
    <Set name="headerCacheSize"><Property name="solr.jetty.header.cache.size" default="512" /></Set>
    <Set name="delayDispatchUntilContent"><Property name="solr.jetty.delayDispatchUntilContent" default="false"/></Set>
    <!-- Uncomment to enable handling of X-Forwarded- style headers
    <Call name="addCustomizer">
      <Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg>
    </Call>
    -->
  </New>

    <!-- =========================================================== -->
    <!-- RewriteHandle to set headers, redirect root to Solr         -->
    <!-- =========================================================== -->
     <New id="RewriteHandler" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
      <Set name="rewriteRequestURI">true</Set>
      <Set name="rewritePathInfo">false</Set>
      <Set name="originalPathAttribute">requestedPath</Set>

      <!-- security-related headers -->
      <Call name="addRule">
        <Arg>
          <New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
            <Set name="pattern">/solr/*</Set>
            <Set name="name">Content-Security-Policy</Set>
            <Set name="value">default-src 'none'; base-uri 'none'; connect-src 'self'; form-action 'self'; font-src 'self'; frame-ancestors 'none'; img-src 'self'; media-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; worker-src 'self';</Set>
          </New>
        </Arg>
      </Call>
      <Call name="addRule">
        <Arg>
          <New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
            <Set name="pattern">/solr/*</Set>
            <Set name="name">X-Content-Type-Options</Set>
            <Set name="value">nosniff</Set>
          </New>
        </Arg>
      </Call>
      <Call name="addRule">
        <Arg>
          <New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
            <Set name="pattern">/solr/*</Set>
            <Set name="name">X-Frame-Options</Set>
            <Set name="value">SAMEORIGIN</Set>
          </New>
        </Arg>
      </Call>
      <Call name="addRule">
        <Arg>
          <New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
            <Set name="pattern">/solr/*</Set>
            <Set name="name">X-XSS-Protection</Set>
            <Set name="value">1; mode=block</Set>
          </New>
        </Arg>
      </Call>

      <!-- redirect root to solr -->
      <Call name="addRule">
        <Arg>
          <New class="org.eclipse.jetty.rewrite.handler.RedirectRegexRule">
            <Set name="regex">^/$</Set>
            <Set name="location">/solr/</Set>
          </New>
        </Arg>
      </Call>
       <Call name="addRule">
         <Arg>
           <New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
             <Set name="pattern">/v2/*</Set>
             <Set name="replacement">/solr/____v2</Set>
           </New>
         </Arg>
       </Call>
       <Call name="addRule">
         <Arg>
           <New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
             <Set name="pattern">/api/*</Set>
             <Set name="replacement">/solr/____v2</Set>
           </New>
         </Arg>
       </Call>
       <Set name="handler">
         <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
           <Set name="handlers">
             <Array type="org.eclipse.jetty.server.Handler">
               <Item>
                 <New class="org.eclipse.jetty.server.handler.InetAccessHandler">
                   <Call name="include">
                     <Arg>
                       <Call class="org.eclipse.jetty.util.StringUtil" name="csvSplit">
                         <Arg><Property name="solr.jetty.inetaccess.includes" default=""/></Arg>
                       </Call>
                     </Arg>
                   </Call>
                   <Call name="exclude">
                     <Arg>
                       <Call class="org.eclipse.jetty.util.StringUtil" name="csvSplit">
                         <Arg><Property name="solr.jetty.inetaccess.excludes" default=""/></Arg>
                       </Call>
                     </Arg>
                   </Call>
                   <Set name="handler">
                     <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
                   </Set>
                 </New>
               </Item>
               <Item>
                 <New id="InstrumentedHandler" class="com.codahale.metrics.jetty9.InstrumentedHandler">
                   <Arg><Ref refid="solrJettyMetricRegistry"/></Arg>
                   <Set name="handler">
                     <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
                   </Set>
                 </New>
               </Item>
             </Array>
           </Set>
         </New>
       </Set>
     </New>

    <!-- =========================================================== -->
    <!-- Set handler Collection Structure                            -->
    <!-- =========================================================== -->
    <Set name="handler">
      <Ref id="RewriteHandler"/>
    </Set>

    <!-- =========================================================== -->
    <!-- extra options                                               -->
    <!-- =========================================================== -->
    <Set name="stopAtShutdown">true</Set>
    <Set name="dumpAfterStart">false</Set>
    <Set name="dumpBeforeStop">false</Set>

    <Call name="addBean">
      <Arg>
        <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
          <Set name="contexts">
            <Ref refid="Contexts" />
          </Set>
          <Call name="setContextAttribute">
            <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
            <Arg>.*/servlet-api-[^/]*\.jar$</Arg>
          </Call>

          <Call name="addAppProvider">
            <Arg>
              <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
                <Set name="monitoredDirName"><Property name="jetty.base" default="."/>/contexts</Set>
                <Set name="scanInterval">0</Set>
              </New>
            </Arg>
          </Call>

          <!-- Add a customize step to the deployment lifecycle -->
          <!-- uncomment and replace DebugBinding with your extended AppLifeCycle.Binding class
          <Call name="insertLifeCycleNode">
            <Arg>deployed</Arg>
            <Arg>starting</Arg>
            <Arg>customise</Arg>
          </Call>
          <Call name="addLifeCycleBinding">
            <Arg>
              <New class="org.eclipse.jetty.deploy.bindings.DebugBinding">
                <Arg>customise</Arg>
              </New>
            </Arg>
          </Call>
          -->

        </New>
      </Arg>
    </Call>

</Configure>

Back to the top