2

Currently, we have tomcat based deployments and one Apache server to manage multiple context path on the same port (v-host configuration)

For example,

ProxyPassMatch /test(.) http://127.0.0.1:7077/test$1*

ProxyPassMatch /test2(.) http://127.0.0.1:7077/test2$1*

and so on

Now we are shifting towards ALB of AWS and we want to map all those context paths in ALB as present in Apache configuration file.

We created ALB --> Listener on 80 Port --> Target created with a Necessary Instance with port 7077 --> health check is passed

Listener rule is,

Context path /test --> Forward to Target Group of 7077 port

Context path /test2 --> Forward to Target Group of 7077 port

But while testing it is showing 502 Bad Gateway when we shut down Apache and to test ALB

Any Solutions?

Devendra
  • 185
  • 14

1 Answers1

2

The Application Load Balancer cannot rewrite the path going to the target like you can with a typical reverse proxy.

https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#path-conditions says:

The path pattern is used to route requests but does not alter them. For example, if a rule has a path pattern of /img/*, the rule would forward a request for /img/picture.jpg to the specified target group as a request for /img/picture.jpg.

Tomcat specific:

Perhaps you can have the tomcat app listen on multiple paths with configuration in context.xml or server.xml. This question has some suggestions, but it seems if you have multiple contexts, the app will run twice and take twice the memory.

Victor Roetman
  • 2,216
  • 2
  • 19
  • 14