I am looking to set up my (Red Hat Linux/Apache 2.2.3) website to allow Ajax calls from HTML5 apps written in Javascript where these scripts might be hosted elsewhere.
This is what CORS is all about.
There are many descriptions of how to enable CORS via mod_headers. Just about all of them set the Access-Control-Allow-Origin header to "*" which opens the site up to the world.
But the Same-origin policy is in place for a reason and this level of access raises real security questions.
How can I whitelist the sites (could be dozens of them, but sites of people I have business relationships with) I want without opening my site to the world?
The only discussion I've seen that discusses this is http://blog.blakesimpson.co.uk/read/64-apache-configure-cors-headers-for-whitelist-domains but:
- That page, while insightful, was not thorough.
- The approach does not look manageable with a largish number of allowed origins.
What are security-conscious web administrators doing?
You can put your all whitelisted domain as below and also define generic regexp match for more flexibel to whitelist domains.