Getting around CORS with IRULES
Our website uses AJAX requests that makes requests from a page delivered from VIP A (www.acmecorp.com) to send requests to VIP B (api.acmecorp.com). We had to go ahead and put in a bunch of headers and do some special logic with IE 8 to allow this to occur. This results in many HTTP Options requests to ensure that the cross-domain origin access is permitted.
The problem is that our of our client's firewall rules are stripping out the HTTP Headers or denying the OPTIONS requests and it is becoming a pain to troubleshoot all of the various vendors.
Ideally I would like to do this for every/get post that used to take the form of this:
api.acmecorp.com/SomeNamedRoute?SomeVariousOptions=X
and instead make it like this:
www.acmecorp.com/api/SomeNamedRoute?SomeVariousOptions=X and then with the IRULE route it to the api.acmecorp.com but the request going to that server should be api.acmecorp.com/SomeNamedRoute?SomeVariousOptions=X
Is this possible?
you can use the ProxyPassV10 irule for this.
your datagroup content would look like this: www.acmecorp.com/api/ api.acmecorp.com/ pool_api_servers
the virtual server's default pool should be the one for the www.acmecorp.com servers and you must use a oneconnect profile in the VS as well.
the proxypass irule will rewrite any request going to www.acmecorp.com/api/XYZ to api.acmecorp.com/XYZ and send it to the pool pool_api_servers proxypass will also take care of the location header in http redirects and rewrite it for you.