0

I have an AWS Elastic Beanstalk application:

enter image description here

As you can see, I am running a Web Server on Tomcat.

After running Google PageSpeed Insights over my website, I see in order to improve performance I need to Enable compression.

I have read here that I need to add a .ebextensions folder to my root folder. Where is that?

I have tried adding it to my webapp folder. Is that correct?

enter image description here

What files do I need to add to this .ebextensions folder? Then do I just upload the app to AWS via the dashboard?

Apologies for being vague, but as you can tell, I am pretty clueless here.

UPDATE

I added this to the root:

.../main/webapp/.ebextensions/apache.config

where apache.config:

files:
  "/etc/httpd/conf.d/gzip.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
        <Location />
        # Insert filter!!!
        SetOutputFilter DEFLATE
        </Location> 

However, when I test it here, I get:

enter image description here

Richard
  • 6,641
  • 15
  • 73
  • 173
  • What are you trying to compress to improve performance? Are you writing data into S3 or something which you would like to compress? – notionquest Jun 09 '17 at 11:55
  • I have a static website with .svg, .png, .jpg, .css & ,html that I would like to compress for performance. – Richard Jun 09 '17 at 11:59
  • Is the `gzip.conf` file being created? YML files are very picky when it comes to whitespace, so the double-indent you have after the `content: |` line might be causing an issue. – Brian Jun 09 '17 at 13:42
  • How do I check if the `gzip.conf` is created? (Excuse my naivety). I am ob AWS Elastic Beanstalk. I copied that `gzip.conf` from someone else's post, so I may have the wrong characters. I will type it out to make sure. – Richard Jun 09 '17 at 15:03
  • Use `eb ssh` to log into your instance, and then see if the file is there with `ls /etc/httpd/conf.d/gzip.conf`. Also, following up on @notionquest's answer, the `apache.config` file needs to be put at the root level of your application on your *development* machine - the configuration commands are executed during the deployment, but the `apache.config` file won't actually be deployed. – Brian Jun 09 '17 at 16:48
  • I followed the advise in the following link, and now I cannot seem to access my server at all. My instance did not have a keypair, and I could access the server via its IP or url. Since I added a keypair, and now it's not accessible. Is this expected behaviour? If so, how do you host a public website on EB? https://stackoverflow.com/questions/4742478/ssh-to-elastic-beanstalk-instance – Richard Jun 12 '17 at 11:18
  • Hi Brian, I managed to set up ssh, and ad a look at the `/etc/httpd/conf.d/`, and there is no `gzip.conf` file. Do you know what else I can try? – Richard Jun 12 '17 at 12:33

2 Answers2

0

The root folder is jbosswildfly in the above case. It shouldn't be added to webapps.

Refer this link for webapps using tomcat

Bundling war file

enter image description here

notionquest
  • 29,710
  • 3
  • 87
  • 92
  • Thanks, I tried that, but I still get: `www.thewhozoo.com is NOT Compressed`. Perhaps the problem is with my `apache.config`? – Richard Jun 09 '17 at 14:50
0

Putting Cloudfront in front of your EB instance is also an option.

There is a checkbox in the behavior settings "Compress Objects Automatically" to enable gzip compression.