Skip to content

Instantly share code, notes, and snippets.

@keymastervn
Last active February 17, 2019 10:33
Show Gist options
  • Select an option

  • Save keymastervn/fd21ac90792a01dfd64c4ba5dd387432 to your computer and use it in GitHub Desktop.

Select an option

Save keymastervn/fd21ac90792a01dfd64c4ba5dd387432 to your computer and use it in GitHub Desktop.
Elastic Beanstalk extension - Nginx example with GZIP configuration
files:
'/etc/nginx/conf.d/01_proxy.conf':
mode: '000644'
owner: root
group: root
content: |
client_max_body_size 10M;
'/etc/nginx/default.d/01_locations.conf':
mode: '000644'
owner: root
group: root
content: |
location /packs {
alias /var/app/current/public/packs;
gzip_static on;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype;
expires max;
add_header Cache-Control public;
if ($request_filename ~* ^.*?\.(eot)|(ttf)|(woff)|(svg)|(otf)$) {
add_header Access-Control-Allow-Origin *;
}
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
}
'/tmp/append_locations.sh':
mode: '000755'
owner: root
group: root
content: |
#! /bin/bash
grep "include /etc/nginx/default.d/01_locations.conf" /etc/nginx/conf.d/webapp_healthd.conf || sed -i '$i\ \ include /etc/nginx/default.d/01_locations.conf;' /etc/nginx/conf.d/webapp_healthd.conf
container_commands:
01_append_locations:
command: "/tmp/append_locations.sh"
02_reload_nginx:
command: 'sudo service nginx reload'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment