Guidance and Advice On How To Setup HTTP Authentication For File Download Webpage WordPress AWS EC2 Ubuntu

I have a wordpress site running on AWS EC2 Ubuntu. I don't know how to technically describe this but here it goes:
I need a page URL that when you go to the URL it will Automatically allow someone to download a CSV file after HTTP Authentication.

I have seen and tried tutorials for setting up a HTTP Authentication for my Admin Sign in page. But I can't find any help on setting up a single page.  I am also up to suggestions on how to setup this HTTP Authentication on AWS S3 Bucket. I hope this makes sense. Thank you for the help.
LVL 1
Dustin StanleyEntrepreneurAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
I have never heard of using HTTP Authentication for a single file, just directories.
0
Shalom CarmelCTOCommented:
The <files> directive can be placed inside "directory" and can refer to a single file by name.
This should work.

<Location "/demo">
	<Files "cat.html">
		AuthBasicFake someuser somepass
	</Files>
</Location>

Open in new window


Apache docs of the <files> directive
https://httpd.apache.org/docs/2.4/mod/core.html#files

For S3, you can only do that by using a CDN in front of S3.
With many CDN services (Akamai, Edgecast, Fastly ...) it is a piece of cake.  

With Cloudfront, you have to inject a Lambda@Edge response. An example is to be found here.

https://gist.github.com/lmakarov/e5984ec16a76548ff2b278c06027f1a4

Or, adapt this AWS example. You have to check for the existence of a specific header with a specific value, and return a 401 error on failure.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-examples.html#lambda-examples-redirect-to-signin-page

Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l

Open in new window

The value is the user & password separated by a colon and base64 encoded.


An example of a full 401 response.
https://en.wikipedia.org/wiki/Basic_access_authentication#Server_side
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dustin StanleyEntrepreneurAuthor Commented:
I thank you all for the help. Just to clarify what my developer has told me is I could use something like:
http://louis:znxah&jfja_@My-Site.com/Files/UploadFile.xml

Open in new window

to upload my file automatically.

The answers above...would this be the easiest route? Thanks.
0
Dustin StanleyEntrepreneurAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AWS

From novice to tech pro — start learning today.