Defect #31085
closedHosting redmine at a suburl doesn't work anymore in 4.0
0%
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
Updated by Bernhard Loos almost 6 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
Updated by Pavel Rosický over 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 ...
Updated by Bernhard Loos over 5 years ago
- Status changed from New to Resolved
This seems to work, thank you.
Updated by Toshi MARUYAMA over 5 years ago
- Status changed from Resolved to Closed
Thank you for your feedback.
Updated by Vincent Robert over 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!
Updated by VVD VVD over 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!
Updated by VVD VVD over 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 endUsers open in browsers URLs:
- http://hostname.domain.local - some custom static content;
- http://hostname.domain.local/redmine - Redmine.
Updated by Robert Auer about 5 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
Updated by Robert Auer about 5 years ago
Found a solution for my problem, see https://www.redmine.org/issues/32318#note-1
Updated by Marius BĂLTEANU about 5 years ago
- Has duplicate Defect #32318: Redmine 4.0 can not be installed in a sub-URI any more added
Updated by keineahnung 2345 over 3 years ago
Thanks, pavel ochman Rosický's solution works for me.
I am using Redmine 4.1.1.
The following is the methods that don't work for me: https://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_a_sub-URI, https://www.phusionpassenger.com/library/deploy/apache/deploy/ruby/#deploying-an-app-to-a-sub-uri-or-subdirectory and https://stackoverflow.com/questions/17753631/how-to-deploy-rails-app-on-subdomain-root-with-apache-and-passenger/17764475.