0

I am using Tomcat7 which is running on port 80.

Services directly to instance IP works just fine but calling services from LB IP throws 502 error.

halfer
  • 19,824
  • 17
  • 99
  • 186
Diptendu
  • 21
  • 1
  • 9

2 Answers2

0

Assuming, you are using managed instance group for maintaining the homogeneous instances. You need to establish a service endpoint which the load balancer can use to direct the traffic. This might be the problem.

I have written the steps to set up an load balancer here. As, load balancer contains lot of moving parts like target proxies, forwarding rules, backend services. It is difficult to debug without any config files. Posting your config here, would help us debug it better.

Community
  • 1
  • 1
Lakshman Diwaakar
  • 7,207
  • 6
  • 47
  • 81
  • Have followed your doc. but somehow tomcat7 doesnot allow to connect to port 80 from load-balancer. So wt i did was just add a nginx layer above tomcat7 and nginx then connects to tomcat7 on default port 8080. Nginx responds to port 80{By Default}. So it worked. – Diptendu Jan 20 '17 at 06:23
0

What I did to make Load balancing (LB) work is mentioned below.

  1. I created a layer of nginx which by default runs on port 80.
  2. I connected to tomcat7 layer using default file of nginx. Tomcat is now running on default port i.e. 8080.
  3. So when LB tries to connect to my instance group it connects through http port 80.
  4. Health check is really important. Health check of LB should pass. To make it pass keep a file on instance group instances. Like "/foo/bar/index.html" on "/var/lib/tomcat7/webapps/foo/bar/index.html". So that LB can directly connect to this file. Once the health check has passed. Then it wont show that instances are unhealthy.
  5. Keep the same health check for instance group. Instance group also checks for same path as mentioned above.
  6. Ideally health check should have passed without keeping this file. But have tried it several times it does not pass the health check the only way to make it pass is to keep that file.
halfer
  • 19,824
  • 17
  • 99
  • 186
Diptendu
  • 21
  • 1
  • 9