Reaction Commerce Forums

Nginx Refused Connection

If anyone has deployed to AWS, I’m having an issue after deploying reactioncommerce/reaction:latest to aws elastic beanstalk, like Sean shows here

I don’t know if this is specific to EB, but has anyone run into an error where nginx refuses a connection to its upstream client?

2018/03/24 16:48:05 [error] 4608#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.37.96, server: , request: "GET / HTTP/1.1", upstream: "http://172.17.0.2:3000/", host: "172.31.2.15"

Hi @lacrx, welcome to the Reaction community and sorry for the late reply!

In case you haven’t figured this out yet, could you please post your Nginx configuration here?

Hi @loanlaux! Thanks for your reply. I ended up figuring it out. It’s specific to Elastic Beanstalk, but I needed to specify the host port as 3000 in the Dockerrun.aws.json file.

But just in case anyone is interested in setting this up with aws, here’s my nginx configuration:

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_delayed_job.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      echo "
      map \$http_upgrade \$connection_upgrade {
          default        \"upgrade\";
          \"\"            \"\";
      }

      server {
         listen    80;
          server_name www.example.com;
          if (\$http_x_forwarded_proto = "http") {
              return 301 https://\www.example.com\$request_uri;
          }
       location / {
         proxy_pass                 http://docker;
         proxy_buffer_size          128k;
         proxy_buffers              4 256k;
         proxy_busy_buffers_size    256k;
        }
       }

      server {
         listen    80;
         server_name example.com;
      return	 301 https://www.example.com\$request_uri;
      }" > /etc/nginx/conf.d/01_setup.conf
      mkdir /etc/nginx/sites-enabled-default
      mv /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy.conf /etc/nginx/sites-enabled-default/elasticbeanstalk-nginx-docker-proxy.conf.default
      service nginx restart

And here’s what I was talking about with the dockerrun.aws.json file. It’s a file that gives aws (in my case, Elastic Beanstalk) a bit of context:

{
  "AWSEBDockerrunVersion": "1",
  "Image": {
    "Name": "reactioncommerce/reaction:latest",
    "Update": "false"
  },
  "Ports": [
    {
      "ContainerPort": "443",
      "HostPort": "3000"
    }
  ],
  "Logging": "/var/log/app.log"
}

Glad you figured it out, and thanks for posting your configuration!