Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Optimized nginx configuration for an AWS Elastic Beanstalk environment using an Application Load Balancer.
files:
"/opt/elasticbeanstalk/#etc#nginx#optimized-nginx.conf":
mode: "000644"
owner: root
group: root
encoding: plain
content: |
# Elastic Beanstalk Managed
# Elastic Beanstalk managed configuration file
# Some configuration of nginx can be by placing files in /etc/nginx/conf.d
# using Configuration Files.
# http://docs.amazonwebservices.com/elasticbeanstalk/latest/dg/customize-containers.html
#
# Modifications of nginx.conf can be performed using container_commands to modify the staged version
# located in /tmp/deployment/config/etc#nginx#nginx.conf
# THIS FILE HAS BEEN MODIFIED BY AN `.ebextensions` SCRIPT
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 65536;
events {
worker_connections 8192;
use epoll;
}
http {
client_max_body_size 100m;
port_in_redirect off;
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" '
'$request_time $upstream_response_time';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
# Elastic Beanstalk Modification(EB_INCLUDE)
log_format healthd '$msec"$uri"'
'$status"$request_time"$upstream_response_time"'
'$http_x_forwarded_for';
include /etc/nginx/conf.d/*.conf;
# End Modification
}
"/etc/security/limits.conf":
mode: "000644"
encoding: plain
owner: root
group: root
content: |
# THIS FILE HAS BEEN MODIFIED BY AN `.ebextensions` SCRIPT
nginx soft nofile 65535
nginx hard nofile 65535
container_commands:
01-mv:
command: "mv -f /opt/elasticbeanstalk/#etc#nginx#optimized-nginx.conf /tmp/deployment/config/#etc#nginx#nginx.conf"
@joselo

This comment has been minimized.

Copy link

commented Feb 26, 2018

Thanks for sharing this file, just a question do you know how I can update this file once the instances have been created?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.