0

I have the following setup:

  • Domain registered mydomain.com
  • App hosted on EC2 webserver on port 80 that's a accessible right now at mydomain.com/myapp
  • .csv files hosted on an S3 bucket named myapp at the following endpoint like so: s3-us-west-2.amazonaws.com/myapp/sample_file.csv
  • Route 53 to deal with CNAME for my domain and an Elastic IP

Everything works fine. However, now I want to update the URL's in my app to mask the longer AWS prefix and replace it instead with: mydomain.com/myapp/sample_file.csv

Every tutorial I've seen deals with subdomains like: myapp.mydomain.com/sample_file.csv which I DON'T want (since this particular app should only be accessed at the /myapp URL)

Is this possible?

Ray
  • 3,137
  • 8
  • 32
  • 59
  • Which weserver/appserver software is running on your EC2 instance? – Dusan Bajic May 04 '17 at 05:19
  • Your domain can *either* point at EC2 or at S3, you'll need to pick one. Alternatively, you could CloudFront in front of the app and send traffic to different origins based on the path. Would you be willing to use a URL like 'files.domain.com/myapp/sample_file.csv` to point to S3? That's easier since it's a different DNS name. – John Rotenstein May 04 '17 at 05:40
  • @JohnRotenstein Yes. Something like `dl.mydomain.com/myapp/file.csv` would be preferred. – Ray May 04 '17 at 05:47

1 Answers1

1

You could point a custom domain name to your Amazon S3 bucket. The basic steps are:

  • Create an Amazon S3 bucket with a name that matches your domain name (eg dl.mydomain.com)
  • Activate Static Website Hosting on the bucket
  • Create a Record Set in Amazon Route 53 for the dl subdomain:
    • Type A
    • Alias = yes
    • Select the Static website for your bucket

Details: Example: Setting Up a Static Website Using a Custom Domain

Then, put objects in the bucket within the myapp directory, eg myapp/file.csv. You will then be able to access the file via: dl.mydomain.com/myapp/file.csv

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470