Host multiple websites on single domain - folder wise on aws s3 - amazon-web-services

I want to have one S3 URL with index.html file and folders on bucket as folder1 and folder2.
Each folder contains build files of respective project.I want to click on folder1 link and go to respective website using AWS s3.
Folder1 link-> Project1
Folder2 link -> Project 2 and so on.
I have tried with creating Bucket on s3 and uploading build to two folders respectively according to project.I have one index.html with two links.
I have index.html file at each project level also.
I am not able to access projects on clicking on respective folder.
Can anyone suggest me something for this?
Thanks in advance.

If the homepage is being served correctly by S3 but the others are not (for a number of reasons), then check the following:
Do the objects exist in the S3 bucket. Check the filenames.
Do the objects have public read access (preferably through the bucket policy).
Does the HTML in your footer for the href go to a valid path. Be careful of relative vs absolute path.
Also check out these troubleshooting pages:
How can I troubleshoot the 404 "NoSuchKey" error from Amazon S3?
How do I troubleshoot 403 Access Denied errors from Amazon S3?

Related

S3 Static site downloads index.html after uploading files

I have a static site that I served to s3 called tidbitstatistics.com
I wrote a script using boto3 to replace the files with new ones and since then, my site doesn't open - instead it downloads the index.html file.
From what I can tell, I didn't change any settings. The site was working fine before I re-uploaded the files. Since then, I deleted all the files and re-uploaded them manually, but I am still running into the same error.
I thought this might have to do with the file types, but they were the correct text/html file types when re-uploading manually and I am adjusting my script to specify file types when calling put_object instead of upload_file with boto3.
Static site hosting is turned on for that bucket and public permissions to read are set. I'm just not sure how s3 all of a sudden won't serve my static site.
I followed the answer here, but I don't see a Content-Disposition property.
Any help would be appreciated - web development is not my strong suit!

How do we host multiple HTML files in a single S3 bucket to get separate URLs for each file?

I'm new to using AWS S3. I need to host my privacy policy HTML page and T&C HTML page in the S3 bucket as static web pages. I need separate URLs for those two files but I can not create separate S3 buckets for each file. So is there any way to full fill my requirement?
I need this kind of URLs after hosting the pages in the S3 bucket
http://<bucket-name>.s3-website-<AWS-region>.amazonaws.com/privacypolicy.html
http://<bucket-name>.s3-website-<AWS-region>.amazonaws.com/termsandcondition.html
also, I can not create an index file for these HTML pages and after that link these HTML pages to that index file, because I need these URLs to link my mobile app. once the user clicks one of the links, the user should go to that page so that's why I need separate URL for these files.
You dont have to create separate bucket
Just create 2 HTML files for example site1.html and site2.html.
Here are the steps to follow
upload site1.html and site2.html
enable website hosting and enter site1.html instead of index.html
turn off block public access setting
add bucket policy to access bucket publicly https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteAccessPermissionsReqd.html
access website using website hosting URL link, this will lead to site1.html, if you want to access site2.html just append site2.html to root address
for example
here is my link for site1.html
http://stack-trial.s3-website.ap-south-1.amazonaws.com/
Note: you can also access the site1.html using this http://stack-trial.s3-website.ap-south-1.amazonaws.com/site1.html.
for site2.html
http://stack-trial.s3-website.ap-south-1.amazonaws.com/site2.html

Site not deployed on AWS S3

I have followed all instructions of deploying React app to AWS S3. Uploaded all files and folders in bucket, but, when clicked on site endpoint in Static Website Hosting shows blank page.What may be the cause? Please see following images for reference
All files and folders uploaded
Static Website Hosting in properties also updated
Public access also enabled
Bucket Policy also updated
Blank Page
This is all required for React App to deploy on AWS S3. Any suggestions?
Fetching index.html works fine, but the various JavaScript files are all yielding 404.
The problem appears to be that your HTML is fetching resources as:
/WeatherApp/static/js/main.057efd26.chunk.js
but in the origin they are actually at:
/static/js/main.057efd26.chunk.js
Fix your index.html to refer to static resources rooted at /static/, not /WeatherApp/static/.
In package.json file, change homepage to: "homepage": "./"
npm run build
re-upload these build files.

AWS S3 Cli get object urls

I want to list the object URLs of all files in my public bucket. I read all the documents about s3 and s3api, but I couldn't find what I was looking for.
I don't want to define the pre-sign URL. I want to list the existing URLs of all files in the folder.
I'm sorry I couldn't add code, but I have a very specific problem and I can't find my starting point.
I'd appreciate it if someone help.
Solution:
https://github.com/cagdasdemirer/AWS-S3-URL-Listing
I don't think there's a direct way to get the URLs of all the S3 files in bucket. This is how can do it:
List all the files in S3 using:
aws s3 ls s3://bucket-name/folder-name
Build a URL like this:
http://s3.amazonaws.com/bucket/key (for path-style URL), or
http://bucket.s3.amazonaws.com/key (for virtual-hosted style URL)
Store it in the folder.
This SO link may help you: https://stackoverflow.com/a/44401684/7541412
Let me know if it helped.
Thanks

Whole new project inside a jekyll project

I have some website projects that I want to show case that have their own index.html files.
I want to make a route in my Jekyll website so that if I go asdf.com/project1/ I would see simply my project1.
Is this possible to do?
My project is deployed on amazon AWS S3 buckets, hosted on Cloudfront. Should I upload to the bucket and set up some kind of routing?
How would I go about doing this?
Thanks.
If you want S3 to show a specific HTML page when navigating to asdf.com/project1/ the easiest way to achieve this is by creating a file with corresponding key project1/index.html in that bucket.
Source here (bottom of page): http://docs.aws.amazon.com/AmazonS3/latest/dev/IndexDocumentSupport.html
You have two options, put those pages inside Jekyll as "projectname/index.html" or an html file without extension.
If you don't want Jekyll to process them and just use the html do not add front matter to it and jekyll will just copy them to the output folder.
Then you may need to set the right content type when uploading the website to the S3 bucket.
You may find helpful to put that into a script: https://simpleit.rocks/having-pretty-urls-in-a-jekyll-website-hosted-in-amazon-s3/