I have a cloudfront distro set up with 2 origins and 2 behaviours to serve my static website (from Default * behaviour) and redirect to a load balancer (from a custom /api/*
behaviour).
After wrestling with security groups for a while now, I finally have cloudfront hooked up to make requests with HTTP. The problem is that it is returning a 404 not found error. I believe that this is because of Cloudfront appending the /api/
to the end of the origin request?
In my logs I can see that this is the origin request Cloudfront is making to my elb http://my-elb-address.us-west-1.elb.amazonaws.com:80/api/
, which if I hit in postman returns a 404 error similar to if I try to go through my cloudfront domain name.
If I hit the first part of that (http://my-elb-address.us-west-1.elb.amazonaws.com:80
) I get a 200 OK.
Is it possible to remove the behaviour path pattern from Cloudfront origin request?
You're confusing path patterns feature (Behaviours) of CloudFront. It doesn't append anything with the request, it just "Forwards" the specific path to the origin you set in the Behaviours. So if you have /api/*
path which you want to forward to Load Balancer then calling CloudFront_URL/api/*
will NOT result in CloudFront_URL/api/api*
on Load Balancer.
As to why the URL without /api/* is working for you is that it's going to the Default behaviour in CloudFront and loading your website from S3.