Setting up pump.io on Debian wheezy

As most identi.ca users (hopefully) know by now identi.ca is scheduled to move to the new pump.io software on June 1, 2013. Pump.io is a new social networking engine made by the same guy that created StatusNet – the software behind the current identi.ca.

I haven’t used identi.ca itself for some time since I opted for installing my own StatusNet instance. The nice thing with both StatusNet and pump.io is that they are federated, which means that people across many different servers can communicate. A bit like email, you can send a message from e.g. the user sazius at the server io.saz.im to another user, e.g. evan at e14n.com. This is in contrast to services like Twitter, where you are locked to one centralised service provider, and you are forced to endure whatever advertising, API or UI changes that they deem necessary.

Anyhow, I decided I need my own pump.io instance as well, so I set out to install it on my Debian “wheezy” based virtual private server (VPS) on gandi. Since there were some tricky parts, I chose to document them in this blog post.

To proxy or not to proxy?

I know the pump.io creator prefers people to setup their instances with their own IP address, and run the node.js-based server directly on a web port (80 or 443). In practice, however, most early adopters are people that are already running their own servers, and don’t want to get a new IP address for each service they are running. So I decided quite early to have pump.io proxied behind a normal web server. People have not had much luck with Apache for this, and I wanted to try out nginx in any case so I went for that.

pump.io and node.js

I started by adding a new pumpio user, since I want it to run without root privileges. Then I installed node.js from source, which went quite smoothly following the instructions in the included README file. I created a local install for the pumpio user.

After this I installed pump.io (again locally for the user) according to the instructions on its web site – again everything pretty straight-forward. I’m using mongodb and the databank-mongodb for that. Mongodb is just an aptitude install away in Debian.

Next I created a config file for pump.io as ~/.pump.io.json, i.e. in the home directory of the pumpio user. This how it looks like right now (I took some hints from jpope’s blog post on pump.io).

{
    "driver":  "mongodb",
    "params":  {"dbname": "pumpio"},
    "secret":  "somethingverysecrethere",
    "noweb":  false,
    "site":  "io.saz.im",
    "owner":  "Mats Sjöberg",
    "ownerURL":  "http://saz.im/",
    "hostname":  "io.saz.im",
    "urlPort": 443,
    "address":  "127.0.0.1",
    "port": 8000,
    "cert": "/path/to/ssl/cert,
    "key": "/path/to/ssl/key,
    "nologger":  false,
    "serverUser":  "pumpio",
    "uploaddir": "/home/pumpio/uploads",
    "debugClient": false,
    "firehose": "ofirehose.com",
    "disableRegistration": true,
    "canUpload": true,
    "sockjs": true,
    "requireEmail": false,
    "noCDN":true
}

Chunked encoding issue

Now, you need to setup nginx as well. This is the tricky part, and I didn’t get it right at first, with people having problems to subscribe. The problem is nginx needs to support something called “chunked encoding”, which doesn’t come built in to the version in Debian wheezy. Fortunately it can be added via the HttpChunkinModule, you just need install the nginx-extras package in wheezy, which is a version of nginx that has several additional modules included. Then write an nginx config similar to mine (again, mostly based on jpope’s config):

upstream pumpbackend {
  server 127.0.0.1:8000 max_fails=3 fail_timeout=30s;
  server 127.0.0.1:8000 max_fails=3 fail_timeout=60s;
  server 127.0.0.1:8000 max_fails=3 fail_timeout=90s;
}

server {
  listen 80;
  server_name io.saz.im;
  rewrite ^ https://io.saz.im$request_uri?;
}

server {
  listen 443 ssl;
  server_name io.saz.im;

  # this is the important chunked encoding stuff
  chunkin on; 
  error_page 411 = @my_411_error;
  location @my_411_error {
    chunkin_resume;
  }

  access_log /var/log/nginx/pump.access.log;
  error_log /var/log/nginx/pump.error.log;

  client_max_body_size 6m;

  keepalive_timeout 75 75;
  gzip_vary off;

  location / {
    proxy_http_version 1.1;
    proxy_set_header Host $http_host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Real-IP $remote_addr;
  
    proxy_redirect off;

    proxy_buffers 16 32k;
    proxy_cache off;
    proxy_connect_timeout 60s;
    proxy_read_timeout 60s;
    proxy_pass https://pumpbackend;
  }
}

That’s it (as far as I can remember). My instance has been up and running for a few days without any problems. If you are using pump.io you can subscribe to me here: https://pump.saz.im/sazius.

Posted by Mats Sjöberg.