Configuring nginx in a single docker container environment (AWS ElasticBeanstalk)

Question:

I am currently deploying a Django + uWSGI app using a single container docker environment in AWS ElasticBeanstalk. This environment already ships with nginx, which I am currently trying to configure.

I am trying to achieve the following:

  1. Terminate HTTPS at the environment’s load balancer
  2. Redirect HTTP requests to HTTPS using nginx (which is shipped with the environment)
  3. Pass requests from nginx to uwsgi

Environment information:

  • Configuration and Solution Stack Name: Single Container Docker 1.11
    version 2.3.0
  • AMI: 64bit Amazon Linux 2016.09 v2.3.0 running Docker
    1.11.2
    2016.09.0
  • Docker Version: 1.11.2
  • Proxy Server: nginx 1.10.1

This is my current configuration:

.ebxtensions/00-loadbalancer-terminatehttps.config

.ebextensions/01-nginx-proxy.config

.ebextensions/02-healthcheckurl.config

application.ini (uwsgi config)

Now, when testing the configuration:

Checking http://test.domain.com/status/ works fine

Checking http://test.domain.com/hello/ doesn’t work as expected. It redirects fine, but it then hangs until the request times out.

Answer:

Following @deviavir’s suggestion, I needed to allow traffic from the load balancer into the EC2 instance.

This is my final configuration:


.ebextensions/00-resources.config:

.ebextensions/01-nginx-proxy.config:

Leave a Reply