Setting up Xymon/Hobbit with nginx

(Ed: This article is outdated, please see the updated version at feld’s site by clicking here)

I just set this up today and it was a pain in the arse, so I figured I’d leave a trace of it somewhere on the internets. I hope this helps you.

First of all, my platform is FreeBSD. You can do this on other platforms, but the most important info is here. If you’re on FreeBSD, you can install the requirements like so:

# portmaster -d www/nginx net-mgmt/xymon-server www/fcgiwrap

Throw in xymon-client if you want it to monitor itself and if you’re not running BSD grab the fcgiwrap code from the nginx site here.

The biggest problem about this setup is that fastcgi isn’t implemented into nginx. This means that your aliases cause issues because the fastcgi script tries to go to the path the webserver gave it not knowing you’re using an alias. It won’t be able to find the files unless you make a symlink that matches your alias… in certain situations you could potentially use symlinks and not define aliases. Use whatever works for you.

Here’s the relevant info you need:

/etc/rc.conf — make sure fcgiwrap runs as the www user


/usr/local/etc/nginx/nginx.conf — or drop this in a vhost

server {
    listen            80;

    root    /usr/local/www/xymon/server/www;
    index   index.html;

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/local/www/nginx-dist;

    location /hobbit/ {
      alias /usr/local/www/xymon/server/www/;

    location /hobbit-cgi/ {
        alias  /usr/local/www/xymon/cgi-bin/;

    location /hobbit-seccgi/ {
        alias  /usr/local/www/xymon/cgi-secure/;

    location ~ ^/.*\.sh$ {
    gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped
    fastcgi_pass  unix:/var/run/fcgiwrap/fcgiwrap.sock;
    fastcgi_param SCRIPT_FILENAME  /usr/local/www/xymon/$fastcgi_script_name;
    fastcgi_param QUERY_STRING     $query_string;
    fastcgi_param REQUEST_METHOD   $request_method;
    fastcgi_param CONTENT_TYPE     $content_type;
    fastcgi_param CONTENT_LENGTH   $content_length;
    fastcgi_param GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param SERVER_SOFTWARE    nginx;
    fastcgi_param SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param REQUEST_URI        $request_uri;
    fastcgi_param DOCUMENT_URI       $document_uri;
    fastcgi_param DOCUMENT_ROOT      $document_root;
    fastcgi_param SERVER_PROTOCOL    $server_protocol;
    fastcgi_param REMOTE_ADDR        $remote_addr;
    fastcgi_param REMOTE_PORT        $remote_port;
    fastcgi_param SERVER_ADDR        $server_addr;
    fastcgi_param SERVER_PORT        $server_port;
    fastcgi_param SERVER_NAME        $server_name;

And now create two symlinks so the fastcgi scripts work.

# ln -sf /usr/local/www/xymon/cgi-bin /usr/local/www/xymon/cgi-bin/hobbit-cgi
# ln -sf /usr/local/www/xymon/cgi-secure /usr/local/www/xymon/cgi-bin/hobbit-seccgi

Securing this page is an exercise left up to the reader.

Enjoy your working Xymon setup on a much more lightweight and responsive webserver.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.