HowTo Install Redmine in a sub-URI » History » Revision 15

Revision 14 (Yehuda Katz, 2013-11-19 16:25) → Revision 15/18 (Simon Deziel, 2016-03-13 21:36)


 h1. HowTo Install Redmine in a sub-URI 

 This page explains how to run Redmine in a subdirectory of your site, for instance @ ; in such a case, you can feel lost because the classic Redmine install does not work directly, and the links to css or javascript files seem to be broken. In this page, we assume you want to run Redmine under "/redmine/" subdirectory of your site. 

 h2.    Using Redmine::Utils (preferred solution) 

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

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

 Then restart your application. 

 h2. Using Rails features 

 Add the following line at the end of your config/environment.rb : 
 ActionController::AbstractRequest.relative_url_root = "/redmine" 
 </pre>Rails will then prefix all links with "/redmine". It can be considered as the simplest, cleanest and most flexible solution. Then restart your application. In more recent versions of Rails the class hierarchy has changed slightly and you will need to use 
 ActionController::Base.relative_url_root = "/redmine" 
 </pre>for the class name. 

 h2. Using Mongrel features 

 If you run Redmine under Mongrel server, you can alternatively use the "--prefix" option of Mongrel : 
 mongrel_rails start --prefix=/redmine 
 _*Mongrel_rails service "--prefix" directive does NOT work with Rails 2.3.x* 
 To fix this issue create a file config/initializers/patch_for_mongrel.rb [name of file can be anything]:_ 
 # Fix for mongrel which still doesn't know about Rails 2.2's changes,  
 # We provide a backwards compatible wrapper around the new 
 # ActionController::base.relative_url_root, 
 # so it can still be called off of the actually non-existing 
 # AbstractRequest class. 

 module ActionController 
   class AbstractRequest < ActionController::Request 
     def self.relative_url_root=(path) 
     def self.relative_url_root 
 # Thanks to 

 You may not run Mongrel on port 80 : if you have an Apache server on the same host, and you run Mongrel on port 8000, you can use the following Apache config to redirect (with Apache's mod_proxy enabled) : 
 ProxyPass /redmine http://localhost:8000/redmine 
 ProxyPassReverse /redmine http://localhost:8000/redmine 

 h2. Using Passenger (aka mod_rails) features 

 If you run Redmine under Apache web server with Phusion Passenger module, you can follow "this guide": ; please note it won't work correctly on some versions of Passenger or some Linux distributions. 

 h2. Using Passenger+Nginx features 

 See "official guide": (This is the only solution that worked for me - 30 Oct 2012) 

 h2. Using Unicorn+Nginx 

 nginx config: 
 location /redmine { 
         alias     <PATH_TO>/redmine/public; 

         try_files $uri/index.html $uri.html $uri @app; 


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

 RedmineApp::Application.routes.draw do 
 scope Redmine::Utils::relative_url_root do 
   root :to => 'welcome#index', :as => 'home' 

 h2. With a reverse proxy 

 If you have an Apache webserver in front of it (with mod_proxy enabled), or an Apache reverse proxy on another machine, you can run Redmine on a specific port and use this kind of config so it appears to be running in a subdirectory : 
 ProxyPass /redmine http://real-redmine-server.localdomain:3000/ 
 ProxyPassReverse /redmine http://real-redmine-server.localdomain:3000/ 
 </pre>See Apache official documentation to adapt it. 

 h2. Old versions of Redmine and Rails 

 If you run a very old version of Redmine (don't know exactly which ones), maybe your version of Rails' ActionController does not support the "relative_url_root" mentionned above. Then you can look at "this page": to reproduce the same behaviour, but it is NOT a very good idea in most cases, you should consider upgrading Redmine. 

 h2. References 

 If this page did not answered your problems, you can see #2508 or "this thread": 

 Windows : Configuring Ruby On Rails App in a subdirectory under Apache - 

 Configuring ruby on rails Action Controller -