Background: I needed to activate GZIP in a Grails 3 app which I’ve deployed with AWS Elastic Beanstalk in a Tomcat 8. I landed in this Stackoverflow question which pointed me in the right direction.
If you want to have a folder in the root directory of your Grails 3 generated war then you will have to create the folder under src/main/webapp.
1. Create the .ebextensions folder
2. Create a myapp.config file under the previously created directory with the next content:
container_commands: 01_setup_apache: command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"
This will trigger the copy of the enable_mod_deflate.conf file to the apache configuration directory.
3. Create enable_mod_deflate.conf file with the next content. You can configure the mime types for which you desire to active deflate.
4. Generate a new war file (with this folder in the root directory) and deploy it to ElasticBeanstalk.
5. Ssh to your EC2 instance and restart apache manually. Note. Restarting the app though ElasticBeanstalk wizard will just restart Tomcat 8.
Do you like to read about groovy development? Yes, then Subscribe to Groovy Calamari a weekly curated email newsletter about the Groovy ecosystem which I happen to write 😉