0

I'm a beginner to deploying web apps on AWS and I believe I have a similar issue to AWS forward port 8000 from elb to port 8000 of EC2 where I have a reactjs frontend and golang api running on aws ec2 and the golang api is running on port 8000 which is accessible via my public_ip:8000 and gaves me messages saying my golang api is operational when I access public_ip:8000. I created the public_ip using Elastic IPs.

I used load balancers to get HTTPS as I have certain features that only work with HTTPS. However when I use my https://domain_name:8000 to send requests to my own API, it says it isn't there and gives me 404 errors when I used an Application Load Balancer.

My domain name uses AWS's Route 53 and AWS nameservers and should have no issues as I am being directed to my normal domain properly. I've added an A record pointing to my load balancer as well.

I've checked the security group used and I have opened up the ports to my IP address.

My Instance Status Checks: Instance Status checks

Below is how I've configured my Application Load Balancer's Target Group: Target groups and for my Listeners I've used HTTP 80, HTTPS 443 and HTTPS 8000 to forward to my target group.

I have tried using classic load balancers as mentioned in the link but they all timeout when I use my domain_name.

Anyone know either a better way to connect or a better way to structure my reactjs frontend and golang backend app on AWS that might need other ports open for api access.

My Classic Load balancer port forwarding config: classic load balancer port

EDIT: I've noticed the problem might be my target group as it says that port 8000 is unhealthy and that the request timed out

mding5692
  • 806
  • 1
  • 10
  • 34
  • low quality question but i suspectthe webserver is not confidureg to handle the expected domain so it returns 404 for security reasons among other considerations –  May 27 '19 at 16:26
  • I added the domain name to the Access-Control-Allow-Origin for handling CORs, the public IP is actually sometimes blocked because I switch around the Access-Control-Allow-Origin to my domain name just to test if it was that – mding5692 May 27 '19 at 16:34
  • I've noticed it says that my port 8000 is unhealthy on the target group, I've checked out the AWS documentation and it isn't really helpful, any clue as to what could be causing the issue? – mding5692 May 27 '19 at 16:55
  • If you want the domain to point to the load balancer you need to add a DNS record. See if the domain is managed by Route 53. If not, find out where the nameservers for the domain are pointing. – AJcodez May 27 '19 at 16:56
  • I've added an A record on Route 53 to the load balancers, it says that the request timed out when I hovered over the unhealthy status for my target group, does that mean a firewall is blocking it out on EC2? The docs and google searches for unhealthy status is not that good – mding5692 May 27 '19 at 16:59
  • can you share results of the adapted command `curl -H "Origin: https://api" --verbose https://api/` –  May 28 '19 at 12:44
  • can you share the mux declaration ? –  May 28 '19 at 12:44
  • I figured it out and just used two EC2 instances, one for the frontend and one for the golang backend – mding5692 May 28 '19 at 15:27

1 Answers1

0

It was taking forever to figure out the ports and none of the google searches or AWS documentation was helpful so I put my reactjs frontend in one EC2 Instance running on port 80 and my server/golang API into another EC2 instance running on port 80 and then set up the Application Load Balancer to forward to a target group with the frontend if HTTP:80 or HTTPS:443 is called and forward to the target group with the golang API if HTTPS:8000 is called.

Make sure that the instances are in the same availability zone as the load balancer or else it won't work properly and also ensure everything is healthy.

mding5692
  • 806
  • 1
  • 10
  • 34