Brief history: I recently moved to new AWS account. And I ported all settings to new account - Route53, CF distributions, S3 buckets, new EC2 instance, RDS etc.
I've managed to make most of it work except for accessing APIs hosted on an EC2 instance on Node running Express server. Note: I AM able to access via ip address (e.g. ipaddress:8000/api/v1). However, not with the domain name - theplaybook.rocks/v1/ap1.
The apex domain works properly (the frontend hosted on S3 with static website hosting and served via CF distribution configured with DNS records) - [theplaybook.rocks][1] works fine.
In the CF distribution I have 2 Origins
- S3 static website - configured with behaviour default path
- EC2 Custom Origin - configured with behaviour /api/* path
Alternate domain names - configured Security policy - TLSV1 (Tried 1.1 as well) Origin Protocol Policy (for EC2 origin) - HTTP only Behaviour for EC2 origin (points I think may help in answering this problem):
- Viewer Protocol Policy - HTTP & HTTPS
- Cache Based on Selected Request Headers - ALL
- Forward Cookies - ALL
- Query String Forwarding and Caching - Forward All, cache based on all
It seems like the CF is unable (or doesn't want to) connect to the Custom Origin.
TLDR:-
http://3.15.153.208:8000/api/v1 works (public IP - so problem is probably not with node/express and ports).
http://theplaybook.rocks/api/v1/ does not work, actually it used to work from different AWS account, just not in new configuration.
PS:- I had the same problem in the old account. And I solved it somehow. And I can't remember how I solved it anymore.
Please help... and I can share more info... let me know. Tks.
Solved. Finally.
I changed HTTP port to 8000 (instead of 80) in Origin settings and it started working immediately.
Note: Previously this was not the case. I never used to put 8000 port here. Not sure why now.
Thanks everyone who glanced by this post :-D