The domain is determined by 3 parameters of the url:
– port number
More information: http://en.wikipedia.org/wiki/Same_origin_policy
To overcome this constraint, at least 3 solutions exist today:
JSONP – JSON with Padding
CORS – Cross Origin Resource Sharing
A value like ‘*’ will allow requests from any domain to call this service. A more restricted value can be applied to limit successful requests from specific domains only.
Apart from this, there are a number of other headers that may/may not be needed for CORS to work depending on your call. Some of them are as below:
Access-Control-Allow-Methods: <comma separated list of methods that the server allows>
Access-Control-Allow-Headers: <comma separated list of headers allowed by the server in the client request>
Apart from this, the server should also support a call to HTTP OPTIONS method which the client calls during a preflight request. The preflight request is made prior to making the actual HTTP request to the desired method and is used to determine the allowed HTTP methods that the server supports and also the allowed origins. When the OPTIONS request returns a successful response, the browser automatically will make the actual HTTP call for the desired method.
Here is a good reference on CORS:
Here is how you can configure the Apache server on a MAC (we are going to use the Apache server which comes installed by default on the latest MAC OS X versions) to act as a passthrough proxy:
Go to Terminal and type in
$ sudo nano /etc/apache2/httpd.conf
In the httpd.conf file, add the 3 lines highlighted below:
ProxyPassMatch /<keyword>/(.*) <destination service domain>/$1
Hit Ctrl+O to write out your changes to the conf file. Hit Enter. Hit Ctrl+X to exit.
Restart your apache server from the Terminal:
$ sudo apachectl -k restart
The important line here is
ProxyPassMatch /<keyword>/(.*) <destination service url>/$1
the server will act as a proxy and make a call to
<destination service url>/<rest_of_the_path>
Using this ProxyPassMatch, we are limiting the Apache server to only act as a proxy for the url calls that have the pattern ‘/<keyword>/’ and to append anything after ‘/<keyword>/’ to the destination url.
For more details on creating a reverse proxy, please refer:
If you have a good explanation, please do post it in the comments.