Create following folder under the working directory.
mkdir .platform/nginx/conf.d/elasticbeanstalk/
Save following nginx.conf
to .platform/nginx/. The configuration file added mapping $status to $logflag, and change the http code from 101 to 0.
cat <<EoF > .platform/nginx/nginx.conf
#Elastic Beanstalk Nginx Configuration File
user nginx;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 32634;
events {
worker_connections 10240;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent" "$http_x_forwarded_for"‘;
include conf.d/*.conf;
map $status $logflag {
101 0;
default 1;
}
map $http_upgrade $connection_upgrade {
default "upgrade";
}
server {
listen 80 default_server;
access_log /var/log/nginx/access.log main;
client_header_timeout 60;
client_body_timeout 60;
keepalive_timeout 60;
gzip off;
gzip_comp_level 4;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# Include the Elastic Beanstalk generated locations
include conf.d/elasticbeanstalk/*.conf;
}
}
EoF
Change healtd.conf
and add if=$logflag to the end of access_log line.
cat <<EoF > .platform/nginx/conf.d/elasticbeanstalk/healthd.conf
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 if=$logflag;
EoF
compress the code and upload to Elastic Beanstalk environment.
Health status of Elastic Beanstalk changed to 'Serve' due to the http code 101
原文:https://www.cnblogs.com/terryares/p/14587794.html