Project

General

Profile

Problem running Redmine on a subfolder

Added by Pall Bjornsson about 9 years ago

Hi There,

I have a Redmine installation at Arvixe on their Linux PersonalClass pro environment, running under https with a valid SSL certificate already installed on the domain.

Redmine version information is the following:

Environment:
  Redmine version                          2.2.4.stable.14542
  Ruby version                             1.8.7 (x86_64-linux)
  Rails version                            3.2.12
  Environment                              production
  Database adapter                         MySQL
Redmine plugins:
  no plugin installed

Redmine is physically installed on /home/username/rails_apps/redmine.

The apache document root is configured as /home/username/public_html

Since I want to run redmine off of the /verk folder, there is a /public_html/verk folder with a .htaccess file with the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.ext$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.ext$
RewriteRule ^(.*)$ "http\:\/\/127\.0\.0\.1\:12010\/$1" [P,L]

This means that mod_proxy is used to proxy Redmine running on localhost.

The url used to access Redmine would therefore be: https://www.domain.ext/verk

I have configured in Administration/Settings/General/Host name and path to be: www.domain.ext/verk

The first access to this Url will show the text content of the Redmine front page, but without all styling, so the page looks bad with only text and links.
However, hoovering over the links on that page, I can see that the links to the modules (like Administration etc.) do not include the /verk in the Url, they only show https://www.domain.ext/xxxx, so no links work.

I have followed http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_a_sub-URI and used the redmine approach, meaning I add to config/environment.rb the following after application init:
Redmine::Utils::relative_url_root = "/verk"

Then I restarted Redmine, but there is no change.

I also tried to add to environment.rb before app initialize:
RedmineApp::Application.routes.default_scope = '/verk'

And also to environment.rb after app initialize:
ActionController::Base.relative_url_root = "/verk"

None of the above worked.

The only thing that does work is to place the same .htaccess file on the document root and that would allow Redmine to be accessed as https://www.domain.ext, but I can not have Redmine at the root so I need to figure out the solution for running it on the /verk sub URI.

All help highly appreciated,
Palli

==== Followup, as I get a 500 error when posting a reply ====

Hi,

Seems that I have figured out the solution. The script_name part of this article (http://stackoverflow.com/questions/3181746/what-is-the-replacement-for-actioncontrollerbase-relative-url-root) was the piece that fixed the problem for me.

The solution is twofold:

1. Add to additional_environment.rb the following line (which take care of css, js etc):
config.action_controller.relative_url_root = "/verk"

2. Modifying config.ru to the following (which take care of the generated Urls for links):

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)

class ScriptName
  def initialize(app, name)
    @app = app
    @name = name
  end

  def call(env)
    env['SCRIPT_NAME'] += @name
    @app.call(env)
  end
end

use ScriptName, '/verk'

run RedmineApp::Application

Not sure if this is fully solving all my problems, but it gets me one step further and now all the links on the main Redmine page seem to be ok and using the sub-URI as I intended.

Palli