3

My goal is 443 (ALB)->8080 (TOMCAT)

I am running a EC2 tomcat instance on 8080.

Here is the tomcat apr connector on 8080

<Connector protocol="org.apache.coyote.http11.Http11AprProtocol"
           port="8080" scheme="http"
/>

I have an ALB listening on 443 with a certificate and set to pass off to a target group 8080.

So the idea is https://www.website.com/myapp -> www.mywebsite.com:8080/myapp

I know my application is running fine because if I open up public access to 8080 I can fully run the app.

I have something misconfigured because when I go to the site https://www.website.com/myapp

I seem to get redirected to: www.website.com/myapp

It seems like I can reach tomcat fine, but then it is redirecting me back to http when it responds. What am I doing wrong?

Thanks!

springcorn
  • 611
  • 2
  • 15
  • 28

3 Answers3

1

Spring Boot application runs on 8080 using the tomcat server. Other applications/servers like apache2 run on 80 port. Ideally, the ALB should point to 80 port and you should set a proxy at 80 which delegate your requests to tomcat (port:8080)

This is how the request will flow:

  1. Accept request at 443 from a browser
  2. AWS ALB catches the request which has a Listener/Target group which coverts (443 to 80)
  3. Now, Proxy server like apache2 should forward request received at 80 to 8080

So you are missing 3rd step which is fairly easy. You can read https://stackoverflow.com/a/33704078/1074100 to configure.

Not to mention, your domain should point to ALB. This can be done in Route53. This helps ALB to receive the request made by the browser. Basically step-1 to work.

0

What worked for me is: I added 2 listeners:

  1. To redirect, HTTP(80) -> HTTPS(443)

  2. Then for the second listener, a forward rule, HTTPS(443) -> My Target for the ALB

Md.
  • 496
  • 4
  • 11
-1

You can use the Redirect rule in your Load Balancer to redirect the request from HTTPS to 8080 port.

Reference: https://aws.amazon.com/about-aws/whats-new/2018/07/elastic-load-balancing-announces-support-for-redirects-and-fixed-responses-for-application-load-balancer/

Steps:

  1. Go to Load Balancer

  2. Add new Listener rule that redirect HTTPS to 8080.

enter image description here

I hope this helps!

Jayesh Dhandha
  • 1,983
  • 28
  • 50