Project

General

Profile

Actions

Defect #31085

closed

Hosting redmine at a suburl doesn't work anymore in 4.0

Added by Bernhard Loos about 5 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

I'm trying to configure redmine for a suburl like http://server/redmine.
In Redmine 3.4, I got it working by adding 'RedmineApp::Application.routes.default_scope = ENV.fetch("RAILS_RELATIVE_URL_ROOT", "/")' to config/additional_environment.rb and setting RAILS_RELATIVE_URL_ROOT, but in Redmine 4.0 this produces an exception.
I tried various other things from HowTo_Install_Redmine_in_a_sub-URI but all of them had various problems (actually, none of them were really working for 3.4 but ohh well).


Related issues

Has duplicate Redmine - Defect #32318: Redmine 4.0 can not be installed in a sub-URI any moreClosed

Actions
Actions #1

Updated by Bernhard Loos about 5 years ago

Exception trace:
rake aborted!
The direct method can't be used inside a routes scope block
/usr/local/bundle/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:2099:in `direct'
/usr/local/bundle/gems/activestorage-5.2.2/config/routes.rb:6:in `block in <top (required)>'
/usr/local/bundle/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:641:in `instance_exec'
/usr/local/bundle/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:641:in `block in with_default_scope'
/usr/local/bundle/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:879:in `scope'
/usr/local/bundle/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:640:in `with_default_scope'
/usr/local/bundle/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:430:in `eval_block'
/usr/local/bundle/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:414:in `draw'
/usr/local/bundle/gems/activestorage-5.2.2/config/routes.rb:3:in `<top (required)>'
/usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in `load'
/usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in `block in load'
/usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in `load'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in `block in load_paths'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in `each'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in `load_paths'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:20:in `reload!'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:30:in `block in updater'
/usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/file_update_checker.rb:83:in `execute'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:10:in `execute'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/application/finisher.rb:130:in `block in <module:Finisher>'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `instance_exec'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `run'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/initializable.rb:60:in `run_initializers'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/application.rb:361:in `initialize!'
/usr/src/redmine/config/environment.rb:14:in `<top (required)>'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/application.rb:337:in `require'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/application.rb:337:in `require_environment!'
/usr/local/bundle/gems/railties-5.2.2/lib/rails/application.rb:520:in `block in run_tasks_blocks'
Tasks: TOP => db:migrate => db:load_config => environment

Actions #2

Updated by Pavel Rosický about 5 years ago

try this

config.ru
require ::File.expand_path('../config/environment',  __FILE__)
map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
  run Rails.application
end

and don't forget to set the variable in your environment, for example

/etc/systemd/system/unicorn.service
[Service]
Environment=RAILS_RELATIVE_URL_ROOT=/redmine
...

Actions #3

Updated by Bernhard Loos about 5 years ago

  • Status changed from New to Resolved

This seems to work, thank you.

Actions #4

Updated by Toshi MARUYAMA about 5 years ago

  • Description updated (diff)
Actions #5

Updated by Toshi MARUYAMA about 5 years ago

  • Status changed from Resolved to Closed

Thank you for your feedback.

Actions #6

Updated by Vincent Robert about 5 years ago

  • Affected version changed from 4.0.2 to 4.0.3

I met exactly the same issue today, upgrading from 3.4 to 4.0.

Thank you Pavel for this solution. It works great!

Actions #7

Updated by VVD VVD almost 5 years ago

Doesn't work for me on fresh installation of 4.0.4 + apache 2.4.39 + passenger 6.0.2. Tried with mod_proxy and without.
Can you show your apache httpd-vhost.conf?
What changes you made in redmine files (config.ru, config/environment.rb, etc.)?

Thanks!

Actions #8

Updated by VVD VVD almost 5 years ago

It work now.

My configs:
$ cat /usr/local/etc/apache24/extra/httpd-vhosts.conf

<VirtualHost *>
    DocumentRoot "/opt/www" 
    ServerName hostname.domain.local
    ServerAlias hostname
    <Directory "/opt/www">
        Options -Indexes -MultiViews
        AllowOverride none
        Require all granted
    </Directory>
    <IfModule mod_proxy.c>
        ProxyTimeout 1800
        ProxyRequests Off
        <Proxy *>
            Require all granted
        </Proxy>
        ProxyPass /redmine http://hostname-redmine/redmine
        ProxyPassReverse /redmine http://hostname-redmine/redmine
    </IfModule>
</VirtualHost>

LoadModule passenger_module /usr/local/lib/ruby/gems/2.6/gems/passenger-6.0.2/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/2.6/gems/passenger-6.0.2
PassengerRuby /usr/local/bin/ruby
PassengerDefaultUser www
PassengerMaxPoolSize 16
PassengerMaxInstancesPerApp 0

<VirtualHost *>
    DocumentRoot "/opt/redmine/public" 
    #Alias /redmine "/opt/redmine/public" 
    ServerName hostname-redmine.domain.local
    ServerAlias hostname-redmine
    RailsEnv production
    <Directory "/opt/redmine/public">
        Options -Indexes +ExecCGI +FollowSymLinks -MultiViews
        AllowOverride none
        Require all granted
        SetEnv RAILS_RELATIVE_URL_ROOT "/redmine" 
    </Directory>
</VirtualHost>

$ cat /opt/redmine/config.ru
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
  run Rails.application
end

Users open in browsers URLs:
Actions #9

Updated by Robert Auer over 4 years ago

Hi!

I am trying to install Redmine 4.0.4 in a Docker container and I want to make it accessible under the '/redmine' sub-URI. I'm experiencing the same problem as described in post 1 and have tried all your solutions already but nothing is working.

Has someone got another solution or can explain what the problem is exactly?

Thanks!

PS: Description of my environment:
PostgreSQL 9.6.10
ruby 2.5.5p157 (2019-03-15 revision 67260)
Rails 5.2.3
Redmine 4.0.4 in alpine linux 3.9.4 Docker container

Actions #10

Updated by Robert Auer over 4 years ago

Found a solution for my problem, see https://www.redmine.org/issues/32318#note-1

Actions #11

Updated by Marius BĂLTEANU over 4 years ago

  • Has duplicate Defect #32318: Redmine 4.0 can not be installed in a sub-URI any more added
Actions

Also available in: Atom PDF