Accessing files from S3 (mounted to EC2) using apache - apache

I am observing that accessing files which is present on s3 mounted to ubuntu EC2 is little slow, when compared to accessing files from ubuntu EC2 itself - through apache.
My configuration is ,
S3 bucket -> Ubuntu EC2 (s3 mounted through s3fs on this machine) . Apache is running on EC2 , and files are accessed using Apache.
What i have observed is, if the request to server is valid ( i.e proper file request) - server takes time to reply, where is some error requests such as file not found or access denied requests are honored immediately.
My question is, has anybody had problems while accessing files sitting S3 buckets when they are mounted to EC2 through apache ( i know i could do cloudfront, but that doesn't serve my purpose as i need to protect files from unwanted access - that's why i have apache rules in place).
Any pointers are greatly helpful.
Thanks.

Don't use S3 for that. Use NAS!

Related

How to Mount S3 Bucket on EC2 Ubuntu Server and Store Web Applications Uploads Directly in that bucket and retrive When User access that Files

I Have Amazon EC2 Instance With Ubuntu 16.04 x64 and Hosted a Web Application on it.
Need to Mount S3 Bucket as one of the Folder and Need to Save User Uploaded Files Directly To S3 Bucket and Retrive When User Access That Files.
I Mounted S3 and Tried Uploading Files, But Files are not Uploading
This might be what you're looking for: https://github.com/s3fs-fuse/s3fs-fuse
BTW network based file systems can be slow for servers, do look into it for any performance issues!

Asp.net core 2.0 site running on LightSail Ubuntu can't access AWS S3

I have a website that I've build with Asp.net core 2.0. The website gets a list of files sitting in my ASW S3 bucket and displays them as links for authenticated users. When I run the website locally I have no issues and am able to access S3 to generate pre-signed urls. When I deploy the web app to LightSail ubuntu I get this incredibly useful error message : AmazonS3Exception: Access Denied.
At first I thought is was a region issues. I changed my S3 buckets to use the same region as my Lightsail ubuntu instance (East #2). Then I thought it my be a CORS issues and made sure that my buckets allowed CORS.
I'm kinda stuck at the moment.
I had exactly the same issue, then i solved it by creating an environment variable. To add environment variable permanently in Ubuntu open the environment file by the following command
sudo vi /etc/environment
then add your credential like this
AWS_ACCESS_KEY_ID=YOUR_KEY_ID
AWS_SECRET_ACCESS_KEY=YOUR_SECRECT_ACCESS_KEY
Then save the environment file, and Restart your asp core app.

How can I host my website on an EC2 Server using Apache but host my images on S3 under the same sub domain?

So I have my website hosted on an EC2 server running apache. All works fine and well.
The issue I'm having is that I want my images hosted on S3 (and possibly cached on CloudFront), not on my EC2 server, but want both accessible under the same domain/subdomain.
For example say my website is www.helloworld.com. I want my images to be accessible at www.helloworld.com/images/foobar.png. I want foobar.png to be hosted on S3 and not each one of my EC2 servers though. How can I go about doing this?
Is there and configuration I can do in the AWS console or are there any rewrite rules I can use in Apache? I know I could always just set up a controller that will download the images from S3 and forward them to the user, but this seems wrong to me.
For that you need to put a load-balancer/proxy in front to intercept all requests and dispatch accordingly. That may not be a bad idea anyway (for availability reasons), but a separate host name for images should not be a problem, either (it's not like users will have to see or type those URL).
Using CloudFront, you can have CloudFront receive the initial requests, then based on the path, forward the request to either your EC2 instance or to your S3 bucket.
For example, you could setup the following:
A CloudFront behaviour that upon a path under /images/ would use an S3 origin, and
A default (for everything else) would go to your EC2 instance origin.

GCS Fuse storage mount issue with apache web server as document root

I'm Trying to mount google cloud storage using fuse tool as apache doucment root for my web server. cloud storage bucket successfully mounted in my apache document root but when i access any file like index.html it showing 403 Forbidden.
I also tried with mount option of uid n gid of apache but still facing same problem.
I had the exactly same issue. I happened resolve it by adding option -o allow_other. Hope it is also helpful for you. Good luck.

Amazon S3 suddenly stopped working with EC2 but working from localhost

Create folders and upload files to my S3 bucket stopped working.
The remote server returned an error: (403) Forbidden.
Everything seems to work previously as i did not change anything recently
After days of testing - i see that i am able to create folders in my bucket from localhost but same code doesnt work on the EC2 instance.
I must resolve the issue ASAP.
Thanks
diginotebooks
Does your EC2 instance have a role? If yes, what is this role? Is it possible that someone detached or modified a policy that was attached to it?
If your instance doesn't have a role, how do you upload files to S3? Using the AWS CLI tools? Same questions for the IAM profile used.
If you did not change anything - are you using the same IAM credentials from the server and localhost? May be related to this.
Just random thoughts...