title: How should I configure Spring Cloud with Netflix Zuul and Eureka in a Docker contained in an EC2 instance
body: <p>I am evaluating building microservices using Spring Boot and Spring Cloud (Zuul and Eureka) running in separate docker containers, deployed in separate Amazon EC2 instances.</p>
  
  <p>I have a simple REST service that registers with Eureka, and have configured Zuul to route requests to this service by looking it up in Eureka.
  <a href="https://i.stack.imgur.com/na8Om.png" rel="noreferrer"><img src="https://i.stack.imgur.com/na8Om.png" alt="enter image description here"></a></p>
  
  <p>I can get this to work running locally (i.e. not in Amazon/EC2) on my Mac using boot2docker, but when deployed on EC2, Zuul cannot find the service, and
  reports a 'Forwarding error' (status 500).</p>
  
  <p>In EC2, everything is configured to run on port 80 (just while evaluating so I can easily access through our firewall). 
  I can see both Zuul and my service in the Eureka system status page (although none of the links work!).</p>
  
  <p>The clients are configured to find Eureka with a full AWS domain name, so I can see how they find Eureka OK.
  e.g.</p>
  
  <pre><code>  client:
      serviceUrl:
        defaultZone: http://ec2-XX-XX-XX-XX.ap-southeast-2.compute.amazonaws.com:80/eureka/,http://ec2-YY-YY-YY-YY.ap-southeast-2.compute.amazonaws.com:80/eureka/
  </code></pre>
  
  <p>But, the clients seem to be registering themselves with their internal docker IP address (based on the Eureka system status links).</p>
  
  <p><a href="https://i.stack.imgur.com/3mwmM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3mwmM.png" alt="enter image description here"></a></p>
  
  <p>The edgeserver link points to <a href="http://172.17.0.2/info" rel="noreferrer">http://172.17.0.2/info</a>
  The trialservice link points to <a href="http://172.17.0.3/info" rel="noreferrer">http://172.17.0.3/info</a></p>
  
  <p>I'm guessing this is incorrect and that other EC2 instances don't know to get to this address.</p>
  
  <p>I've read this page <a href="https://github.com/Netflix/eureka/wiki/Configuring-Eureka-in-AWS-Cloud" rel="noreferrer">https://github.com/Netflix/eureka/wiki/Configuring-Eureka-in-AWS-Cloud</a> which suggests using AWS EC2 Elastic IP addresses, but
  I was hoping I wouldn't have to do this.</p>
  
  <p>I've also seen there is a current discussion around this subject here, <a href="https://github.com/spring-cloud/spring-cloud-netflix/issues/432" rel="noreferrer">https://github.com/spring-cloud/spring-cloud-netflix/issues/432</a></p>
  
  <p>Has anyone managed to get this type of setup working, and if so, how did they configure the Eureka properties?</p>