What
SolutionStack: 64bit Amazon Linux 2016.03 v2.1.3 running Ruby 2.3 (Puma)
の場合
Where
nginx用の設定はファイルは/etc/nginx/conf.d/webapp_healthd.conf
だけど、こいつはsymlinkなので、実体は/opt/elasticbeanstalk/support/conf/webapp_healthd.conf
How
.ebextensions
を使う
.ebextensions/nginx.config
commands:
01_nginx_status:
command: |
sed -i -e ':loop; N; $!b loop; ;s/r healthd;\n\n location \/ {/r healthd;\n\n location \/nginx_status {\n stub_status on;\n access_log off;\n allow 127.0.0.1;\n deny all;\n }\n\n location \/ {/g' /opt/elasticbeanstalk/support/conf/webapp_healthd.conf
これが
/opt/elasticbeanstalk/support/conf/webapp_healthd.conf
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
location / {
proxy_pass http://my_app; # match the name of upstream directive which is defined above
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
こうなる
/opt/elasticbeanstalk/support/conf/webapp_healthd.conf
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
location /nginx_status
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location / {
proxy_pass http://my_app; # match the name of upstream directive which is defined above
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
ある程度冪等性を考慮してるので、毎回実行されても問題ない。