Setup Bamboo with Nginx

Using Nginx as a frontend for web apps has several advantages:

  • static files are served by nginx
  • application could pick a random port
  • free gzip on response
  • speed

Steps to setup Nginx with Bamboo

Static files

http {

  ...

  server {
      listen       80;
      server_name  jinjing.funkymic.com;

      location ~ ^/(theme|plugin|images|dl|media)/ {
        root   /home/jinjing/scm/git/haskell/jinjing-blog/public;
      }

      ...
  }
}

All it does is to let Nginx serve several sub paths under the blog's public path, e.g. public/theme.

Enable gzip

http {
    ...

    gzip  on;
    gzip_http_version 1.0;
    gzip_vary on;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_buffers 16 8k;
    gzip_disable “MSIE [1-6].(?!.*SV1)”;
    gzip_types 

      text/plain
      text/html
      text/xml
      text/javascript
      text/css
      application/json
      application/x-javascript 
      application/xml
      application/xml+rss
      ;


    ...

Reverse proxy to Bamboo app

server {
    ...

    location / {
        proxy_pass http://localhost:3000; 
    }
}

That's it.

I also use an in-house cache middleware to cache any response from the blog. Whenever I update a post, I remove the cache database. It's not ideal, but good enough for my stupid blog.

With this setup, there's no space leak, no file handles leaks and performance can be squeezed to above 350 requests/sec.

blog comments powered by Disqus