Trying to deploy a Docker image in AWS Elastic Beanstalk running on a single instance for now. It all works fine, apart from WebSockets which I am using through Socket.IO. <
You're correct that the nginx configuration file does not exist when ebextensions are run. Here's why: that config file is dynamically generated after the application is deployed because the port mapping for the Docker container isn't known until after the container stops. So your awesome Python script executed by ebextensions doesn't have a config file to operate on.
Another conventional approach doesn't work, i.e., writing the nginx config file to /etc/nginx/conf.d because the location
directive has to exist inside the server
block in the sites_enabled
config. So that's a no go.
I created a PR to illustrate an approach that will work: https://github.com/svenkreiss/databench_examples/pull/3 This is an undocumented technique that drops the Python/nginx mutation script into the right place in Elastic Beanstalk's hooks directory. The script is then executed by Elastic Beanstalk immediately after the nginx configuration is generated (Elastic Beanstalk will run executable scripts in the hooks subdirectories in alphabetical order, hence the 01_
prefix.
Thanks,
Evan