Static website hosting is working in the root directory, but this is not working for me:
my.bucket/index.html
my.bucket/subfolder/index.html
https://s3-eu-west-1.amazonaws.com/my.bucket works as expected
https://s3-eu-west-1.amazonaws.com/my.bucket/subfolder doesn't work (Access Denied)
Is this possible?
There are (at least) three ways to access a static website hosted in AWS.
The S3 bucket name
The CDN name. (which is what the "host a static website" wizard tells you to use)
The "Static website hosting endpoint" which is listed on the S3 bucket management page
Only the "static website hosting endpoint" filters incoming requests to give Apache like behaviour; S3 is a RESTful API for storing files with no concept of subfolders.
If you have used the wizard, there is "Manage file in S3" in tiny text at the bottom left of the screen, which will open up the correct page in the console for you, then click the 'properties' button.
You need to modify the permissions of the sub-folder as well to make it publicly accessible.
Related
I have created my portfolio website, so now I would like to upload it on AWS s3.
I bought a custom domain name for it, but before using it, I can't even host my website with the endpoint URL (something like this: http://masahiro-takechi.com.s3-website-us-west-1.amazonaws.com). When I copied and pasted it on Google, it says "This page isn't working".
I believe I set proper settings to be able to host the website such as permissions and Static website hosting, and so on. Permissions are totally public, unblock access, generate correct bucket policy, and upload right folders and files like index.html.
All tips would help me greatly, thanks for your time to help me in advance!!;)
Your website should be in a root folder of the bucket. Otherwise, you have to access it using your folder:
http://masahiro-takechi.com.s3-website-us-west-1.amazonaws.com/engineer_portfolio_resume/index.html
I made a bucket lets call it my bucket. I gave "Legacy Storage Read" to this bucket and it means that it should not list the buckets but if someone knows the URL of specific files or folders inside the buckets they could visit it.
If I enter the only bucket address in URL I get access denied even though, I added index.html ( which is in the root of the bucket) as the main page in the bucket website configuration. Anyone has any idea why the bucket does not routed to index.html if I just go to the bucket URL?
Have you configured your permision? If this is not the case you can try below steps.
For full details you can refer to this link
In the Google Cloud Console, go to the Cloud Storage Browser page.
Go to Browser
Click the Bucket overflow menu () associated with the bucket to which you want to grant a member a role.
Choose Edit bucket permissions.
Click the + Add Members/Principal button.
In the New members field, enter one or more identities that need access to your bucket. If you want to serve your bucket to the public, then type allUsers
Select a role and grant Storage Legacy Object Reader(or roles) from the Select a role drop-down menu. You can check at (Legacy Role Permision reference).
Click Save.
Also, below steps is to route your bucket to desired html file.
For full details you can refer to this link Static website examples and tips
In the Google Cloud Console, go to the Cloud Storage Browser page.
Go to Browser
In the list of buckets, find the bucket you created.
Click the Bucket overflow menu () associated with the bucket and select Edit website configuration.
In the website configuration dialog, specify the main page and error page.
Click Save.
To learn how to get detailed error information about failed operations in the Cloud Storage browser, see Troubleshooting.
It seems like you are trying to connect directly to the object URL in your bucket.
If your goal is to setup a static website you have to configure the permissions of your bucket so it is accessible to the public and the set up a Load Balancer to serve it.
To configure the permissions for your bucket you can follow the steps here.
You can test if they are properly configured by trying to access the object with their URL http://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME, I recommend using a Incognito window to make sure it is accessible for all users.
Once you have configured the permissions you have to configure the Load Balancer, which you can do following this guide.
Please note that even though the guide says you need a domain you can test this feature by leaving the "Frontend configuration" as default and connecting directly to the Load Balancer IP address.
The changes to the "Edit website configuration" option in the buckets are applied to the Load Balancer.
I'm setting up an S3 bucket behind CloudFront that is meant to serve static assets. My problem is doing a / on any directory with no file name will have the browser download a download.txt with 0 bytes. I have my S3 bucket setup for Static Website Hosting and is pubic, so I'm able to access my assets.
https://s3-bucket.domain.com/path/to/file.jpg -> get asset, working
https://s3-bucket.domain.com/path/to/file-bad-name -> Error status 403, working. Renders error.html from S3.
https://s3-bucket.domain.com/path/to/ -> sends download.txt, not working
How do I configure #3 to not send a download.txt and render an error page instead?
There are few things happening there.
You need to map it to new origin if you want to point the path to an S3 object.
Your pattern is not having priority in CloudFront.
If you fix one of the above or both, then it should work as expected.
I have my S3 bucket setup for Static Website Hosting and is pubic
...but you selected the bucket from the dropdown list when defining the origin... yes?
You need to configure the origin domain name to use the web site hosting endpoint for the bucket.
When you configure your CloudFront distribution, for the origin, enter the Amazon S3 static website hosting endpoint for your bucket. This value appears in the Amazon S3 console, on the Properties page under Static Website Hosting. For example: http://bucket-name.s3-website-us-west-2.amazonaws.com
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistS3AndCustomOrigins.html#concept_S3Origin_website
If you don't do this, and you created folders in the bucket using the S3 console, then what you are currently observing is the expected behavior, a side effect of the way the console creates those imaginary folders.
I am trying to host my static application on aws s3 bucket. I have put my build folder files in bucket. It looks like this
But when I go to .s3-website..amazonaws.com index.jade gets downloaded instead of webapp getting opened.
I followed this tutorial https://www.fullstackreact.com/articles/deploying-a-react-app-to-s3/
How can I get my web app work?
Update:
When I changed content type of index.jade to text/html, the browser shows html text like this
Here is how I edit metadata key in aws console
now there is no download. But still web page is not getting served.
You need to enable static site hosting on your S3 bucket. To enable website hosting for an Amazon S3 bucket
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.
In the list, choose the bucket that you want to use for your hosted website.
Choose the Properties tab.
Choose Static website hosting, and then choose Use this bucket to host a website.
You are prompted to provide the index document and any optional error documents and redirection rules that are needed.
Make sure to keep your bucket ACL as public. Also you need to parse your jade files to html.
I am hosting a website using Amazon S3 and Route 53 as part of their Amazon Web Services. The site is up and running fine but would like to be able to easily keep track of how many people visit the site?
I know you have resolved this, but I hope it will help someone else.
Below is a copy/paste from relevant page of AWS site made on Nov 18 (use this link to page for latest version) :
If you want to track the number of visitors who access your website, enable logging for the root domain bucket. Enabling logging is optional.
To enable logging for your root domain bucket
Open the Amazon S3 console at https://console.aws.amazon.com/s3/.
Create a bucket for logging named logs.example.com in the same AWS Region that the example.com and www.example.com buckets were created in.
Create two folders in the logs.example.com bucket; one named root, and the other named cdn. If you configure Amazon CloudFront to speed up your website, you will use the cdn folder.
In the Bucket name list, choose your root domain bucket, choose Properties, and then choose Server access logging.
Choose Enable logging.
For Target bucket, choose the bucket that you created for the log files, logs.example.com.
For Target prefix, type root/. This setting groups the log data files in the bucket in a folder named root so that they are easy to locate.
Choose Save.
You can now review your logs in the logs.example.com bucket, in both the root and cdn folders.
You can use any third-party counter in exactly the same way you would have it on non-S3 site. Do you experience any problem with any particular counter?