title: How can I set max header size from environment variables in a Spring Boot application
body: <p>I have some SpringBoot 1.5.19.RELEASE services hitting problems because the our Keycloak bearer token is getting big. In the short term, rather than reduce the token size we want to increase the maximum acceptable header size instead.</p>
  
  <p>Lots of stack overflow pages <a href="https://stackoverflow.com/questions/57889575/how-to-set-max-http-header-size-in-spring-boot-2-x-application">suggest that setting <code>server.max-http-header-size=48000</code> in <code>application.properties</code></a> should relieve the symptom and it does. I can also successfully use that from the command line as a system property <code>-Dserver.max-http-header-size=48000</code>. But even changing the command line for all of our services is a little tedious as the commmand line is embedded in each docker image so I wondered about an environment variable which can be changed at deployment time...</p>
  
  <p><a href="https://docs.spring.io/spring-boot/docs/1.3.0.BUILD-SNAPSHOT/reference/htmlsingle/#_environment_properties" rel="nofollow noreferrer">Spring docs</a> suggest that <code>application.properies</code> can also be overridden from the environment using the <code>RelaxedPropertyResolver</code> allowing e.g. <code>spring.profiles.active</code> to be set from the <code>SPRING_PROFILES_ACTIVE</code> environment variable. This works well and I've used it many times.</p>
  
  <p>But trying my services with an environment of <code>SERVER_MAX_HTTP_HEADER_SIZE=48000</code>,  <code>SERVER_MAX-HTTP-HEADER-SIZE=48000</code>, and even  <code>SERVER_MAXHTTPHEADERSIZE=48000</code> results in the default limits being applied - nothing seems to be recognised by Spring.</p>
  
  <p>How can I specify this setting via an environment variable without having to rebuild the docker images etc that run the services?</p>