Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've recently set up Gollum with Nginx running the backend stuff.

The wiki repository is stored in /path/to/root/todos (it's a to-do wiki). Because of the way Gollum works, however, if it can't find a page on the wiki, it automatically tries to create one (which is great), but rewrites the url as follows:

http://www.domain.com/todos/foobar (doesn't exist yet and will be created) gets rewritten to http://www.domain.com/create/foobar. Now, unless I set up a separate entry for each possible uri that Gollum uses in its own directives, we get a 404 error here.

To circumvent this, I added the following to my nginx config:

```

location / {
    index index.php;
    try_files $uri /$uri /todos/$uri;
}

```

This works, but it will not accept the index. If I go directly to domain.com/index.php, I can view the index page as intended. However, going directly to the site (domain.com) instead redirects to the index for the wiki. (domain.com/create/home). I don't understand this behaviour, as it is only supposed to route to to-dos (which is a proxy_pass directive to the Gollum port) if the original $uri can't be found, and index.php exists.

What am I doing wrong here? It seems like such a simple issue, but this doesn't make any sense to me.

Any assistance would be greatly appreciated.

share|improve this question

2 Answers 2

Make a location /todos/ block to contain the try_files directive since you are doing the redirecting if a non-existent URI is found only in the todo directory. And it's generally recommended to put the index directive in the server block if it's not different for different location blocks. (This is not relevant to this issue, though)

server {
    .............
    .............
    index index.php;

    location /todos/ {
        try_files $uri $uri/ /create/$uri;
    }

    ............
    ............
}

In your configuration, the second parameter for the try_files /$uri makes no sense unless you are trying to redirect http://www.domain.com/todos/foobar to http://www.domain.com/foobar. A succeeding front slash denotes a directory whereas a preceeding slash just denotes a root level file/directory.

share|improve this answer
    
location /todos/ is where I have the proxy pass to the Gollum port. Gollum does not know about /todos/, and does not write URLs with /todos/ in it. That is why I mentioned above that Gollum tries to reach the URL at domain.com/create/foobar, instead of /todos/create/foobar. The problem is that for some reason index index.php is being ignored, and try_files isn't attempting to find index.php first. –  Tom Thorogood Dec 20 '12 at 18:38

I just found this page when having the same issue, ≈2 years later.

My solution didn't involve any nginx hacking, but using the option flags in gollum. --base-path, should take care of this issue. Try instantiating gollum with:

$ gollum /path/to/root/todos/ --base-path todos

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.