0

The EC2 is configured correctly, Elastic Ip is attached and the domain is pointing to EC2 linux machine.

Everything is working perfectly fine. But the problem is that all 3 Elastic IP, The Public DNS provided by EC2 and the domain that I pointed to EC2 machine are all displaying the same content and i don't want that. I only want the website or the domain to display the contents and both elastic IP and the public dns should be inaccessible to public or the internet. How do i do that can someone please help?

I want this to work like for instance you bought a dedicated vps package from hostpapa or from a similar hosting provider. The dedicated IP's that they provide you are only accessible until you've connected a domain. The moment you configure the domain and assign one of the dedicated Ip to that domain. The connection from that ip address when ran on a browser gives you either a webmaster error or server not found. I am looking for that kind of solution

Roy
  • 1
  • 3
  • Check https://stackoverflow.com/questions/32772341/disable-web-access-via-direct-ip-address-on-aws-opsworks-nginx-unicorn-server – αԋɱҽԃ αмєяιcαη Mar 07 '20 at 00:45
  • One way would be to setup ALB, and place SGs on the instances to allow incoming traffic from only Seciurity Group of the ALB. Second way, would be to use CloudFront and use custom headers to reject all requests on your instance which don't dont have these headers. – Marcin Mar 07 '20 at 00:47
  • With CloudFront you could also restrict access to your instance to only [IPs associated with CF](https://aws.amazon.com/blogs/security/how-to-automatically-update-your-security-groups-for-amazon-cloudfront-and-aws-waf-by-using-aws-lambda/). – Marcin Mar 07 '20 at 01:01
  • Thank you for the comments. But neither of this would work. I am seeking some instruction through server side blocks through .hatcess or something similar. Are there any apache configuration that can disable the access to the IP when entered on a browser. – Roy Mar 07 '20 at 01:24
  • I want this to work like for instance you bought a dedicated vps package from hostpapa or from a similar hosting provider. The dedicated IP's that they provide you are only accessible until you've connected a domain. The moment you configure the domain and assign one of the dedicated Ip to that domain. The connection from that ip address when ran on a browser gives you either a webmaster error or server not found. I am looking for that kind of solution. – Roy Mar 07 '20 at 01:32
  • I think you're describing a [virtual host](https://httpd.apache.org/docs/2.4/vhosts/examples.html) where multiple domain names are served from the same IP address. In such situations, the server is unable to provide a website when accessed via IP address because the domain was not provided (and hence it doesn't know which website to display). – John Rotenstein Mar 07 '20 at 07:26
  • I agree with @JohnRotenstein, this is a virtual host configuration issue within apache – Vorsprung Mar 07 '20 at 08:08
  • @John Rotenstein so how do I tell ec2 instance that the website is connected and working. To tell you honestly all everything is working. The public DNS provided by ec2 is displaying the files that I uploaded to the system, the elastic IP that I generated that is also showing the same files, then I connected the domain and that is also showing the same files. Now the problem is that all of this are displaying my files. But I just my domain to display the files and rest to be become inaccessible if accessed through browser. – Roy Mar 07 '20 at 11:38
  • Please use the **virtual host** information I linked above. – John Rotenstein Mar 07 '20 at 12:05

0 Answers0