사내 발표자료 겸 만들었는데, ECS Fargate를 이용하실 분들이라면, 편리하게 쓰실 수 있도록 최대한 상세하게 만들어 보았습니다.
사실 CloudFormation 등 배포는 좀 더 편리하게 할 수 있지만, 회사 사정도 있고, 제가 일단 그런 기술을 너무 늦게 알았기 때문에 다루지는 않았습니다.
46. files:
"/etc/nginx/conf.d/01_proxy.conf":
mode: "000644"
owner: root
group: root
content: |
client_max_body_size 10M;
"/etc/nginx/conf.d/02_app_server.conf":
mode: "000644"
owner: root
group: root
content: |
# The content of this file is based on the content of /etc/nginx/conf.d/webapp_healthd.conf
# Change the name of the upstream because it can't have the same name
# as the one defined by default in /etc/nginx/conf.d/webapp_healthd.conf
upstream new_upstream_name {
server unix:///var/run/puma/my_app.sock;
}
# Change the name of the log_format because it can't have the same name
# as the one defined by default in /etc/nginx/conf.d/webapp_healthd.conf
log_format new_log_name_healthd '$msec"$uri"'
'$status"$request_time"$upstream_response_time"'
'$http_x_forwarded_for';
server {
listen 80;
server_name _ localhost; # need to listen to localhost for worker tier
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/access.log main;
# Match the name of log_format directive which is defined above
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour new_log_name_healthd;
location / {
# Match the name of upstream directive which is defined above
proxy_pass http://new_upstream_name;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /assets {
alias /var/app/current/public/assets;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
location /public {
alias /var/app/current/public;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
47. files:
"/etc/nginx/conf.d/01_proxy.conf":
mode: "000644"
owner: root
group: root
content: |
client_max_body_size 10M;
"/etc/nginx/conf.d/02_app_server.conf":
mode: "000644"
owner: root
group: root
content: |
# The content of this file is based on the content of /etc/nginx/conf.d/webapp_healthd.conf
# Change the name of the upstream because it can't have the same name
# as the one defined by default in /etc/nginx/conf.d/webapp_healthd.conf
upstream new_upstream_name {
server unix:///var/run/puma/my_app.sock;
}
# Change the name of the log_format because it can't have the same name
# as the one defined by default in /etc/nginx/conf.d/webapp_healthd.conf
log_format new_log_name_healthd '$msec"$uri"'
'$status"$request_time"$upstream_response_time"'
'$http_x_forwarded_for';
server {
listen 80;
server_name _ localhost; # need to listen to localhost for worker tier
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/access.log main;
# Match the name of log_format directive which is defined above
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour new_log_name_healthd;
location / {
# Match the name of upstream directive which is defined above
proxy_pass http://new_upstream_name;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /assets {
alias /var/app/current/public/assets;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
location /public {
alias /var/app/current/public;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
files:
"/etc/nginx/conf.d/01_proxy.conf":
mode: "000644"
owner: root
group: root
content: |
client_max_body_size 10M;
"/etc/nginx/conf.d/02_app_server.conf":
mode: "000644"
owner: root
group: root
content: |
# The content of this file is based on the
# Change the name of the upstream because
# as the one defined by default in /etc/ng
upstream new_upstream_name {
server unix:///var/run/puma/my_app.sock;
}
# Change the name of the log_format becaus
94. Unable to locate credentials.
You can configure credentials
by running "aws configure".
‘aws configure’ .
!
https://docs.aws.amazon.com/ko_kr/cli/latest/userguide/cli-chap-configure.html
166. Only private subnets are supported for
the awsvpc network mode. Because
tasks do not receive public IP
addresses, a NAT gateway is required
for outbound internet access. Inbound
internet traffic should be routed through
a load balancer.
167. If you are using Fargate tasks, a public
IP address needs to be assigned to the
task's elastic network interface,. The
network interface must have a route to
the internet or a NAT gateway that can
route requests to the internet, for the
task to pull container images.