What is the port number of the web application to which default proxy config on AWS elastic beanstalk forward requests to?

Viewed 1681

The confusion has occurred as on this page under "Reverse proxy configuration" it has been mentioned so :

By default, Elastic Beanstalk configures the proxy to forward requests coming in on port 80 to your main web application on port 5000.

And on this page it has been mentioned like so:

By default, Elastic Beanstalk configures the proxy to forward requests to your application on port 8080.

So is it port 5000 or is port 8080 the default port to which the requests are forwarded?

3 Answers

On Amazon Linux 2 it is 8080. You can check it by inspecting default nginx setting on the EB instance:

cat /etc/nginx/conf.d/elasticbeanstalk/00_application.conf 

location / {
    proxy_pass          http://127.0.0.1:8080;
    proxy_http_version  1.1;

    proxy_set_header    Connection          $connection_upgrade;
    proxy_set_header    Upgrade             $http_upgrade;
    proxy_set_header    Host                $host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
}

The 5000 could be from Amazon Linux 1, not sure about it.

If you're using Amazon Linux 2 and the docker platform, the default port is 8000.

cat /etc/nginx/conf.d/elasticbeanstalk-nginx-docker-upstream.conf 
upstream docker {
    server 172.17.0.2:8000;
    keepalive 256;

This is the default ElasticBeanstalk with docker setup:

Request hits port port 80, this hits instance which goes to Nginx Proxy, where it's forwarded to Docker that by default exposes it's services on port 8000.

By default ElasticBeanstalk runs a listener on port 80, you can confirm it in AWS ElasticBeanstalk environment by checking:

enviornment name > configuration > load balancer > Listeners

You can confirm Nginx forwarding port by running:

$ cat /etc/nginx/conf.d/elasticbeanstalk-nginx-docker-upstream.conf 

upstream docker {
    server 172.17.0.2:8000;
    keepalive 256;

And check the Docker's expose port by running:

$ cat /var/app/current/Dockerfile

FROM python:2.7

# Add sample application
ADD application.py /tmp/application.py

EXPOSE 8000

# Run it
ENTRYPOINT ["python", "/tmp/application.py"]
Related