Github style wiki with smeagol and nginx

16:10 , , , , 0 Comments

It's been a while I've been looking for a wiki tool like github, to provide some sort of git based wiki for the company.
The idea was to have the company's repos listed somewhere so I could click on them and see the wiki pages within each repo, just like github.

For my ignorance, I accidentally found a gem called gollum which github is supposed to be based on.
Also there is the smeagol gem which uses gollum and provides a read only multi repo access to git based wikis.

Smeagol supports multiple repos but it requires a different hostname for each repo, which is not very practical. I want to have something like company.com/repo-name, just like github, where "repo-name" is a different git repo.

I came up with a solution using nginx proxy_pass. It forges the hostname for smeagol based on the url provided.

First create your smeagol configuration file:


port: 8089
git: /home/dev
auto_update: true
cache_enabled: true

repositories:
  - path: /home/dev/repo1
    cname: repo1
  - path: /home/dev/repo2
    cname: repo2

Then the nginx vhost configuration file:

server {
   server_name hostname;
   listen 80;

   location ^~ /smeagol {
      proxy_pass        http://localhost:8089;
      proxy_set_header  X-Real-IP  $remote_addr;
   }

   location ~ ^/[^/]+/?(.*) {
      rewrite  ^/([^/]+)/?(.*)$  /$2  break;
      proxy_pass        http://localhost:8089;
      proxy_set_header  X-Real-IP  $remote_addr;
      proxy_set_header Host $1;
   }
}

Now run everything and you should be able to use http://YOURHOST/YOURREPO/

Voilá.

0 comments: