Elastic Beanstalk: customize Puma configuration

We use Ruby+Passenger, but it sounds similar enough to your situation. We need to customize the nginx configuration file stored at /opt/elasticbeanstalk/support/conf/nginx_config.erb, so we do it via .ebextensions and sed.

Here's an example to get you started:

.ebextensions/01-edit-nginx.config

container_commands:
  01backup_config:
    command: "cp -n /opt/elasticbeanstalk/support/conf/nginx_config.erb /opt/elasticbeanstalk/support/conf/nginx_config.erb.original"
  02edit_config:
    command: "sh -c \"sed '/string_to_insert_text_after/ i\
\    text_to_be_inserted;' /opt/elasticbeanstalk/support/conf/nginx_config.erb.original > /opt/elasticbeanstalk/support/conf/nginx_config.erb\""

This will make a backup copy of the configuration file (without overwriting it if it already exists, thanks to the -n flag) and then insert the line "text_to_be_inserted" after the line "string_to_insert_text_after". You can pipe multiple sed commands together to insert multiple lines.