Skip to content

Instantly share code, notes, and snippets.

@devops-1
Created May 31, 2017 23:00
Show Gist options
  • Save devops-1/b4e2f57390b740f494b6856c00dbf740 to your computer and use it in GitHub Desktop.
Save devops-1/b4e2f57390b740f494b6856c00dbf740 to your computer and use it in GitHub Desktop.
00_nginx.config
container_commands:
01-nginx:
command: /opt/elasticbeanstalk/hooks/configdeploy/enact/35_nginx.sh
files:
"/home/ec2-user/nginx.conf":
mode: "000644"
owner: root
group: root
content : |
upstream nodejs {
server 127.0.0.1:8081;
server 127.0.0.1:8082;
server 127.0.0.1:8083;
server 127.0.0.1:8084;
keepalive 256;
}
server {
listen 8080;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
access_log /var/log/nginx/access.log main;
location / {
proxy_pass http://nodejs;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
gzip on;
gzip_comp_level 4;
gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
}
"/opt/elasticbeanstalk/hooks/configdeploy/enact/35_nginx.sh":
mode: "000755"
owner: root
group: root
content: |
cp -f /home/ec2-user/nginx.conf /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf
cp -f /home/ec2-user/nginx.conf /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment