Nginx as a proxy for cross domain ajax requests

Maxim Dounin mdounin at mdounin.ru
Wed Sep 12 07:55:08 MSD 2007


Hello!

On Mon, 10 Sep 2007, Alex Egg wrote:

> OK,
> So assuming I did the above, how would I access the proxy from inside nginx?
> What URL would I give to javascript?

In the example I've written, the url "/local-ajax-endpoint" in your domain 
will be prixied to remote site. So you should use "/local-ajax-endpoint" 
(or and absolute variant with domain specified) in javascript.

Maxim Dounin

>> On Mon, 10 Sep 2007, Alex Egg wrote:
>>
>>> Hello,
>>> Is it possible to use nginx as a proxy for cross domain ajax requests?
>>>
>>> if so, how?
>>
>> If you know destination domain for request - just use pre-configured
>> proxy_pass. E.g.:
>>
>> location /local-ajax-endpoint {
>>     proxy_pass http://example.com/axaj-endpoint-on-remote-site;
>> }
>>
>> It is not currently possible to use proxy without prior knowledge of
>> destination domain.
>>
>>
>> Maxim Dounin
>>
>>
>





More information about the nginx mailing list