Search code examples
nginxurl-rewritingredminethin

Nginx with redmine as sub uri doesn't work


I installed redmine with thin and nginx on my raspberry pi. I am able to access my redmine installation using http://raspberrypi/. However I want it to be http://raspberrypi/redmine.

My current (working) nginx site config looks like this:

upstream redmine {
  server unix:/var/run/thin/redmine.0.sock;
}

server {
  listen 80;
  server_name raspberrypi;
  root /usr/share/redmine/public;

  location / {
    proxy_pass http://redmine/;
  }
}

When I change the location line to location /redmine { I can access redmine using http://raspberrypi/redmine but all links are pointing to http://raspberrypi/ without "redmine" appended and are not working.


Solution

  • Add the following line at the bottom of your config/environment.rb

    Redmine::Utils::relative_url_root = "/redmine"
    

    Start the thin server with --prefix /redmine, in my case:

    thin start --prefix "/redmine" -s1 --socket /tmp/thin.sock
    

    Change your nginx configuration to:

    location /redmine {
       proxy_pass http://redmine/redmine;
    }
    

    Also look at the documentation.