AWS Elastic Beanstalk - Custom Domain Problem with Route 53 hosted zone - amazon-web-services

Hi i have laravel app deployed with AWS Elastic Beanstalk.
I have domain on cloudflare, I created hosted zone in AWS Route 53 with A record which is alias to my Elastic Beanstalk env but if i want to access app with this domain it just doesnt work, if i create A record with EC2 ip associated with Elastic Beanstalk env everything works, but when autoscaling pops up this ip changes, I tried to point DNS with CNAME to .elasticbeanstalk domain associated with app but same result, anyone had similar problem?
I tried using dig mydomain and answer section gives me 2 ip addresses - typing both to browser lets me access application, but neither of those two are same as ec2 intance associated with Elastic Beanstalk env,
I also tried using DNS Checker online, seems like some DNS servers reads my domain as those two IP addresses from dig command, some DNS servers reads my domain as a combination of EC2 instance address + one of address displayed in dig command
Any idea what can cause this? Server works on amazon linux + nginx on which i used certbot to get SSL Certificates (all 80 port requests are pointed to 443 port which seems working - because after typing http://domain I get 301 redirect to https://) nginx -t tells that configuration of nginx is ok

The problem was lack of HTTPS listener in load balancer.
To resolve something like this:
Go to configuration
Find Load Balancer and Edit
Add Listener for 443 Port HTTPS and SSL certificate

Related

Point EC2 instance to GoDaddy domain

I already have a domain, like exmaple.com and I have a simple app running on an ec2 instance.
I've allocated an elastic IP for this instance, and created a zone on route 53, created A record, and also an alias record.
I have updated the nameservers from route53 NS records in GoDaddy domain settings(and I should mention that I've waited 48 hours for ns to be propagated, and that part is fine).
When I ping example.com on my own computer, the DNS Name resolve to the correct IP address.
When I check the elastic IP, it's working and shows my website, but when I check example.com it does not show my app and shows This site can’t be reached:
this is a screenshot of what it shows
I cannot see where's the problem!
Based on the comments.
The issue was due to using https, rather then http. The http connection works. To setup https the following general procedure needs to be undertaken:
Get a public SSL certificate. Since you are using instance, you can't use AWS ACM for that. In this case a popular choice is https://letsencrypt.org/ where you can register free SSL certificate for your domain and its subdomains.
Setup ssl connectivity on your instance. Often this is done by using nginx as a revers proxy. The nginx will provide HTTPS for your instance using the SSL certificates from step 1.
Open port 443 (HTTPS) in your security group.
The alternative is to front your instance with an application load balancer (ALB). Using it, you can easily get free AWS ACM free certificate and deploy it on the ALB. No actions required on your instance in this case.

Access AWS ALB via HTTPS from localhost

I have an AWS setup with ECS and ALB. The ALB has https listener which I am trying to configure the SSL Certificate for and forward the traffic to my ECS task.
My problem here is that in development environment we run the application using localhost, and when trying to send data to the ALB and ECS task, traffic gets rejected, because I cant add localhost as my domain is the SSL.
Is there any way I can solve this problem?
Maybe you can add your domain name in your hosts file.
127.0.0.1 dev.example.com
That way, when you request dev.example.com, it will go to your localhost.
Your local application can then talk to the ALB and your browser will see it with the right SSL certificate.
The issue was in Route53 and the record sets. I created a new subdomain in Route53 services.example.com, with A Record Type and Alias targeting the ALB. Then used this subdomain in frontend.
There is no need to add anything to hosts file.

Route53 alias for S3 and EC2

I'm sure I'm missing something simple here, but my problem is this. I'm hosting my web app on aws as an Elastic Beanstalk application. The EC2 instance created has a load balancer associated with it.
I also have a domain registered on aws, and on Route 53, I have an A type configured for the domain and the alias target is the load balancer. That's all working fine.
I also wish to host a static html page for my domain. But to do that according to this - https://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html#root-domain-walkthrough-add-arecord-to-hostedzone, I also need to create another A type alias in Route 53 for the S3 bucket.
The problem is I cant seem to be able to have both. Is there a way to configure my load balancer and/or Route 53 settings to be able to host and serve my static website and my elastic beanstalk instance?
No. Unless you use a reverse proxy like Nginx (in front of ELB) to serve your static page (hosted on S3) on different port or port 443 but on different uri like https://<yourdomain.com>/static and serve your Elastic Beanstalk web app on port 443 on uri / like https://<yourdomain.com>.
<yourdomain.com> -> DNS A record -> Nginx server -> route to ELB or your static page (hosted on S3) depending on which port/uri was requested.
OR
Host your static html page on an EC2 instance and setup a rule on ELB to route requests with /static in URL path to that EC2 instance.
https://aws.amazon.com/blogs/aws/new-aws-application-load-balancer/

How to link godaddy domain with application running on aws

I'm running into this problem trying to link my Godaddy domain with a AWS Elastic ip.I google it and got many documents on how to link a EC2 instance with a domain on Godaddy.I followed following steps :
1: I created a new Elastic ip, and mapped to my instance aws.
2: Edit godaddy A(Host) to point to this elastic ip.
But when i am pointing to my domain name i.e http://example.com it is showing my Jboss server console.I find and got that the war file name should be ROOT.war but i am running multiple application on same server so how can i point this domain to my specific application like "http://MyExample/index.jsp"
You can simply use any reverse proxy server like Nginx and create a configuration there to map the domain to the application running on the server.
Assuming your application is running on 127.0.0.1 at port 8081 on the server then nginx config would have something like
proxy_pass http://127.0.0.1:8081;
Use an application load balancer! Avoid NGINX for reverse proxying like a curse especially if you're going to down stream to an elastic load balancer that is fronting an elastic beanstalk.
Because you really should be removing your EC2 instance and running elastic beanstalks for your apps anyway :P

Amazon Route 53 setup subdomain to point to Load balancer

I have 2 services running on AWS.
Lets say my domain is example.com
I run both of them through Elasticbeanstalk.
One is a single EC2 instance with a elastic IP setup and running on the apex - example.com and www.example.com which works correctly and i can access it.
The other one is a service that has a load balancer in front and i want it to be accessible through sockets.example.com which i cannot get to work.
I have the route 53 nameservers setup in namecheap.com from where i bought the domain.
Here is my whole setup:
EDIT:
I can get the URl from the alias target and open it in a browser for example or ping it. That works.
I have the loadbalancer setup to forward the traffic from 80 to 8080 where my sockets are because of the root access rights for attaching them with sockets i was unable to set them up on the lower ports such as 80. But i don't think thats the issue since i am running a node.js app and i can open a sample page if i go straight on the Alias target URL.
Did you set your ELB up as public or internal?