Skip to content


nginx and BOSH / Comet connections

Yesterday I was scratching my head badly, why on earth my development BOSH installation (I am developing a web based Jabber client) did not work, while the production one did fine. After digging (telnet and hand crafted HTTP+XMPP requests did the job well) I found out, that my local nginx installation was “to new”.

The latest nginx version does proxied request caching. It buffers the proxied server response and pushes it to the client as a whole. It does help in mitigating client-backend bandwidth differences, but breaks Comet requests like the BOSH one. There is an option added to nginx for this very purpose: proxy_buffering. You need to disable the buffering: proxy_buffering off;.

So, the complete BOSH proxy location should look like this:

location /http-bind/ {
proxy_buffering off;
tcp_nodelay on;
keepalive_timeout 55;
proxy_pass http://xmpp.server:5280/xmpp-httpbind/;
}


Posted in HowTo, Jabber/XMPP.

Tagged with , , , , .


7 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. sunbaoming says

    same problem with me.
    I use nginx 0.7.59 and nginx 0.8.x , all response my bosh request with 301 Moved Permanently. and I get crasy now.
    would you please tell me what’s the version of nginx worked?

  2. Tomasz Sterna says

    $ nginx -v
    nginx version: nginx/0.7.59

  3. sunbaoming says

    it looked like nginx don’t support XEP-1024 POST data. when post always return status code 301 but when GET /http-bind , it worked.

    maybe nginx would check posted data , but xep-0124 data is not a valid normal http package so refused by nginx.

  4. Tomasz Sterna says

    Maybe you should post to /http-bind/ instead of /http-bind ?

  5. sunbaoming says

    hi Tomasz,would you please test you nginx with openfire 3.6.4 . download from http://www.igniterealtime.org/downloads/index.jsp. openfire http-bind url is http://x.x.x.x:7070/http-bind .

    my conf:

    location /http-bind {
    proxy_pass http://127.0.0.1:7070;
    }

  6. Tomasz Sterna says

    No I would not. I am jabberd2 and Tigase user and have no interest in OpenFire.

    Try changing to:
    location /http-bind/ {

    as I shown in my example config.

  7. YaoCl says

    Have you got it work with https.

    I can config it with http but https not work
    server {
    listen 443;
    sslengine on;
    location /http-bind/ {
    proxy_pass http://127.0.0.1:5280/http-bind;
    }

You must be logged in to post a comment.