Search code examples
amazon-web-servicesamazon-ec2rhel

Force Webpage to be Inaccessible on AWS EC2


I have a website that is being hosted in an AWS EC2 instance. I am using AWS RHEL (the default EC2 option).

Currently, my hosted site (on the instance) is located at: /var/www/public_html/gitRepoName/index.html.

Lets say I have 3 webpages in the directory gitRepoName. So, that would be index.html, aboutMe.html, and adminPage.html. How can I configure the instance such that nobody can manually type in myUrl.com/adminPage.html and get the admin page as a result?

In other words, how do I make sure that my individual webpages can only be accessed via clicking proper href tags I made, and they cannot be accessed by hard-typing in a link. Please comment with any questions.

Thanks in advance for the help!


Solution

  • This is something you have to build on the web page and not on the ec2 itself.You can use php script to get the HTTP_REFERER and check the value is equal to "myUrl.com/index.html"

    The code in adminPage would be something like below:

      <?php
        $ref=$_SERVER['HTTP_REFERER'];
       if ($ref!="myUrl.com/index.html")
       {
          ......redirect to index.html
       }
       ?>
    

    I have mentioned the php example since you have not mentioned what script language you are using.If you are using HTML/Javascript then try with document.referrer property in HTML dom.