Skip to content

Instantly share code, notes, and snippets.

@wearhere
Last active April 16, 2022 17:53
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save wearhere/19a035423ffe0c940f060ea825926391 to your computer and use it in GitHub Desktop.
Save wearhere/19a035423ffe0c940f060ea825926391 to your computer and use it in GitHub Desktop.
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
Copy link

joselo 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