Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a server using nginx as a reverse proxy which is passing requests for foo.example.com to the port 80 forwarding is working perfectly fine but I also need to forward port 9292 for a javascript messaging service.

My server{} entry for the 9292 server is:

    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;

But when I go to the application my chrome console gets this error:

Unexpected response code: 400 

And then loads of this error:

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

It is able to request the initial javascript from the server at http://foo.example.com:9292/faye.js but after that I just get this error.

Everything I'm reading implies that this should be working fine so what am I missing?

share|improve this question

1 Answer 1

After a bit of twaeking I managed to solve the Access-Control-Allow-Origin Issue but the Unexpected Response Code: 400 was because web sockets don't work through reverse proxies yet.

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

share|improve this answer
Can you explain what you meant by "a bit of tweaking"? –  denaje Jul 28 '14 at 19:17
I tweaked our firewall to let faye talk directly the webserver instead of going through the reverse proxy –  Arcath Jul 29 '14 at 20:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.