Access-Control-Allow-Origin与nginx反向代理

我有一个服务器使用nginx作为反向代理,它将foo.example.com的请求传递到10.0.0.210端口80转发工作正常,但我也需要转发端口9292的JavaScript消息传递服务。

我的服务器9292服务器{}条目是:

server{ listen 9292; server_name foo.example.com; location / { add_header Access-Control-Allow-Origin http://foo.example.com; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://10.0.0.210:9292; } } 

但是当我去应用程序我的铬控制台得到这个错误:

 Unexpected response code: 400 

然后加载这个错误:

 XMLHttpRequest cannot load http://foo.example.com:9292/faye. Origin http://foo.example.com is not allowed by Access-Control-Allow-Origin. 

它可以从http://foo.example.com:9292/faye.js服务器请求最初的JavaScript,但之后我只是得到这个错误。

我正在阅读的一切意味着这应该工作正常,所以我错过了什么?

经过一番小小的调整,我设法解决了Access-Control-Allow-Origin问题,但意外的响应代码:400是因为networking套接字不能通过反向代理工作。

参见: https : //github.com/faye/faye/issues/24#issuecomment-391508