Force Webpage to be Inaccessible on AWS EC2 - amazon-web-services

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!

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.

Related

How to host multiple reactJs web app under one domain in amplify?

I've 2 different reactJs applications which can be deployed independently to aws-amplify. Is there a way I can configure them to the different context paths of the same domain?
www.mydomain.com/app1
www.mydomain.com/app2
Is it possible using amplify?
Right now there is no way to deploy multiple projects with different subdirectories on the same domain using different amplify projects.
But there is a way to deploy multiple projects under the same domain name in a single amplify project instance. If your project is using a monorepo style of structuring the projects. You can read more about it here .
The closest thing I've figured out is adding subdomains before
Let me know if you figure this out because I'm trying to do the same thing
I'll keep you posted as well
Amplify documentation says you can use "200 redirects" (or "Reverse proxy rewrite") to deal with this issue.
cf. https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html
I quote :
Rewrite (200)
200 redirects (rewrites) are intended to show content from the
destination address as if it were served from the original address.
Search engine ranking history continues to apply to the original
address. Redirection occurs on the server-side, so a browser
navigation bar shows the original address after redirection.
So you may want to create 2 redirect rules :
/app1/<*> https://app1.mydomain.com/<*> 200
/app2/<*> https://app2.mydomain.com/<*> 200
(choose any domain/subdomain you want for your app1 and app2)

How to host static website of 'multiple pages' on google cloud

I have followed everything from the above link. By following the link .I had hosted my website on google cloud. My static website contains multiple pages(5 pages). In the hosted website I cant find images and other html pages except "index.html" page.
Can anyone please help me by letting me know how to host static website of multiple pages and letting me know how to keep my website secured?, so it would be very helpful for me.
https://codelabs.developers.google.com/codelabs/cloud-webapp-hosting-gcs#5
i think reason behind image is not loading is
you examine the file paths for your files, also be sure that you spelled the name of the image correctly.
refer this link for more details.
Since you didn't provide any more details I can only give you some pointers on what to focus on.
Create a bucket named www.yourdomain.com - www is very important unless you just want to use just yourdomain.com.
Change access permissions so everyone can read it's contents.
Upload your files to the main directory. When someone accesses the site first file that GCP will look for is index.html so make it your home page. Make sure you uploaded all of them. If the images in your page are stored in a folder (img, images etc) then upload that folder with the files inside to your bucket. From your description it looks like either you're missing them or they are in the wrong folder.
Obtain your own SSL certificate or use GCP's managed certificate (free of charge)
Set up a load balancer
Point your domain to your LB's external IP
At that point you're ready to go and your site is up & running.
If this is the first time you're doing it I recommend to start from readin official documentation on how to set up a static website in GCP.
You can access your site without using load balancer to check if it's running correctly by using a link in the format https://storage.googleapis.com/my-bucket/my-object. Have a look at the truobleshooting static websites to get more insight.
Have a look at my other answer covering this topic: https://stackoverflow.com/a/64442826/12257250
Alternatively you can try hosting your site using firebase.

http_referer empty on aws

I'm trying to access the http_referer in a bitnami wordpress install on aws. It's returning an empty string even tho I'm loading the page from another page in the site, not by directly entering the url.
Same code worked before I moved the site to AWS.
Am I missing something?
The Bitnami WordPress Cloud Image doesn't block or strips the HTTP_REFERER. Apache and PHP are not configured to modify it.
I recommend you to take a look to the next SO case:
In what cases will HTTP_REFERER be empty
There you'll find a bunch of possible reasons why it could be empty. The problem could be related with your browser or the Firewall configuration on your Server.

Hosting a Tumblr blog on Amazon Web Services as subdomain

How do I use a custom (sub)domain (or secondary page) on AWS to 'host' a Tumblr blog?
I'm using Amazon S3, CloudFront, and Route 53 to host a static website. The static news/blog section I've made lives under http://wavefrontbiometric.com/news.html. So far, so good.
Now I've set up a blog/news page on Tumblr (so http://wavefrontbiometric.tumblr.com) that I want to have replace http://wavefrontbiometric.com/news.html. I understand that this might need to change to a two-level structure http://news.wavefrontbiometric.com/), and that's fine.
So far I've tried following these instructions from Tumblr, but with no luck. I've added a 'Hosted Zone' on Route 53 for http://news.wavefrontbiometric.com/, but failed to point the C-NAME record to 'domains.tumblr.com'.
Basically I'm using Tumblr as a backend for the news page only. Users shouldn't be able to notice any visual difference from any other page. I've already got my HTML & CSS markup perfected.
Any help is much appreciated. Thank you.
The only interaction between Tumblr and your (sub)domain is Route53. No other services are needed. Your subdomain should be a CNAME as shown in the instructions; if that isn't working, something is wrong in your Tumblr configuration, which is outside the scope of stackoverflow.

Run fuel php app in AWS EC2 instance

I have a fuel php application created by one of my friend.Now I want to run it on aws EC2 instance(ubuntu).I can run the application using apache2 and its index page is loading.After facebook connect from index page it is supposed to show my fb friends list. But it is showing a 404 error POST http://ec2xxxxcompute.amazonaws.com/ajax/auth/facebook not found
I can see a get_facebook() method inside controller(/ajax/auth.php).But it is not catching the method.My top level understanding is i need some url mapping in server level.
Can anyone help me to run the app.Any suggestion will be highly appreciated as a biginner
Are any other URL's loading, or only the index page? If that is the case, it might be a rewriting issue.
Is the default .htaccess file still included in the /public folder? Or did your friend change it?
You may not actually be calling your php code at all. Don't you need something like :
http://ec2xxxxcompute.amazonaws.com/ajax/auth.php/facebook