pramodtech
pramodtech

Reputation: 6270

What is elastic IP on Amazon EC2? is it okay if I don't use it?

I have hosted a RoR app on Amazon EC2 instance. Instance has public IP but no elastic IP is assigned. Application is pointed to a domain using Dreamhost.

We use Amazon S3 to store audio files uploaded through web application and load these files back to site and play in player.

This is where I am facing weird issue, sometimes files play fine but sometimes it gives error saying

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin http://XX.XXX.XX.XXX is therefore not allowed access.

But at the same time if I copy paste S3 url in browser outside my application it loads.

Why error gives IP address instead of saying mydoamin.com is therefore not allowed access?

I am guessing the issue is because of some domain/IP configurations.

Upvotes: 2

Views: 438

Answers (1)

Uri Agassi
Uri Agassi

Reputation: 37409

An elastic IP on amazon is an IP which is reserved to you. Without it, every time you stop and start your instance, a different IP will be set to it.

You don't have to use elastic IP, you could, for example point your domain to an ELB (elastic load balancer) CNAME, which will remain constant as it load balances between one or more instances of your application.

I'm not sure this has anything to do with the error given, which is explained in this answer:

Site B uses Access-Control-Allow-Origin to tell the browser that the content of this page is accessible to certain domains. By default, site B's pages are not accessible to any other domain; using the ACAO header opens a door for cross-domain access by specific domains.

Site B should serve its pages with

Access-Control-Allow-Origin: http://sitea.com

It seems that the problematic link is an absolute path with the explicit IP, I have no idea why this should happen, look at the source of the page from which the link fails, and try to figure it out.

Upvotes: 2

Related Questions