title: Update config on running ElasticBeanstalk Tomcat instance
body: <p>I have deployed a Spring Boot REST application as a WAR into an AWS Elastic Beanstalk Tomcat 8 + Java 8 instance. Subsequently, I realized that I need to configure the following settings (applies to the <a href="https://tomcat.apache.org/tomcat-8.0-doc/config/http.html#Standard_Implementation" rel="nofollow noreferrer">Tomcat server.xml</a>):</p>
  
  <pre><code>compression="on"
  compressionMinSize="2048"
  compressableMimeType="text/html,text/css,..."
  </code></pre>
  
  <p>because <code>application.properties</code> in Spring Boot applies only to embedded Tomcat containers. It is too late to change the platform type of the Elastic Beanstalk instance now. Is there any way to update the configuration from the Elastic Beanstalk CLI, using <code>eb config</code>? I was looking at this <a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-after.html#configuration-options-after-ebcli" rel="nofollow noreferrer">AWS page</a>, and it looks like it may be possible.</p>
  
  <p><strong>Updated 01/16/2017</strong>
  Thanks to the answer from @dave-maple I started looking in the relevant parts of Elastic Beanstalk documentation.</p>
  
  <p>First, I discovered that Apache is the default proxy server. I could have changed it to nginx, but I didn't have any particular justification to go that route.</p>
  
  <p>Second, I found that adding an <code>.ebextensions</code> folder to the top level of my Spring Boot project. I did not want to <em>pollute</em> my code base with a cloud provider specific configuration file, but it seemed to be the lowest hanging fruit. So I went for it.</p>
  
  <p>I added the following hierarchy:</p>
  
  <pre><code>MySpringBootProject
   |
   +- src
       |
       +- main
           |
           +- resources
               |
               +- ebextensions
                   |
                   +- httpd
                   |   |
                   |   +- conf.d
                   |       |
                   |       +- enable_mod_deflate.conf
                   |
                   +- myapp.config
                   |
                   +- tomcat-settings.config
  </code></pre>
  
  <p><em>Contents of</em> <strong>tomcat-settings.config</strong></p>
  
  <pre><code>option_settings:
    aws:elasticbeanstalk:environment:proxy:
      GzipCompression: 'true'
  </code></pre>
  
  <p><em>Contents of</em> <strong>myapp.config</strong></p>
  
  <pre><code>container_commands:
  05-restart-apache:
      command: "sudo /etc/init.d/httpd restart"
  </code></pre>
  
  <p><em>Contents of</em> <strong>enable_mod_deflate.conf</strong></p>
  
  <pre><code># mod_deflate configuration
  &lt;IfModule mod_deflate.c&gt;
    # Restrict compression to these MIME types
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xml+rss
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE image/png
    AddOutputFilterByType DEFLATE image/gif
    AddOutputFilterByType DEFLATE image/jpeg
  
    # Level of compression (Highest 9 - Lowest 1)
    DeflateCompressionLevel 9
  
    # Netscape 4.x has some problems.
    BrowserMatch ^Mozilla/4 gzip-only-text/html
  
    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
  
    # MSIE masquerades as Netscape, but it is fine
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
  
    &lt;IfModule mod_headers.c&gt;
      # Make sure proxies don't deliver the wrong content
      Header append Vary User-Agent env=!dont-vary
    &lt;/IfModule&gt;
  &lt;/IfModule&gt;
  </code></pre>
  
  <p><em>Add the following lines to</em> <strong>pom.xml</strong> (to set up the <code>.ebextensions</code> folder in the top level of the generated WAR file):</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
      &lt;configuration&gt;
          &lt;webResources&gt;
              &lt;resource&gt;
                  &lt;directory&gt;src/main/resources/ebextensions&lt;/directory&gt;
                  &lt;targetPath&gt;.ebextensions&lt;/targetPath&gt;
                  &lt;filtering&gt;true&lt;/filtering&gt;
              &lt;/resource&gt;
          &lt;/webResources&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>I could have sworn this worked, because I saw the <code>Content-Encoding: gzip</code> response header... only a couple of times. Any idea what could be happening?</p>