Redmine in a sub-URI, with nginx + Unicorn
Added by Frédéric MOULIS about 9 years ago
Hi,
first, I'm sorry if the answer that works for me is already somewhere, but I did not find it.
I'm trying to run redmine on a sub-URI (https://my.domain/redmine) on a server where I already had nginx installed. I've looked at http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_a_sub-URI and applied the "Using Unicorn+Nginx" directives but it did not work. After some searches on the web, I found many different solutions, none worked for me. I hope you will be able to help me.
Currently, when I try to load the URL https://my.domain/redmine, the Redmine welcome page is displayed, so I assume the problem is not in the nginx configuration, but please feel free to ask me about it if you don't agree :) My problem is that none of the links in this welcome page take into account the /redmine relative path (e.g the "register" link refers to https://my.domain/account/register instead of https://my.domain/redmine/account/register). So I cannot do anything, neither register, nor login, nor anything else.
Here are my modifications on Redmine and Unicorn configuration files :
I launch redmine+unicorn by running this script :cd /etc/redmine && unicorn_rails -c /home/service/shared/config/redmine/unicorn.rb -p 5000 -E production -D
File /home/service/shared/config/redmine/unicorn.rbworker_processes 4
working_directory "/etc/redmine" # available in 0.94.0+
listen "/home/service/shared/socket/redmine/unicorn.sock", :backlog => 64
listen 8080, :tcp_nopush => true
timeout 30
pid "/home/service/shared/pid/redmine/unicorn.pid"
stderr_path "/home/service/shared/log/redmine/unicorn.stderr.log"
stdout_path "/home/service/shared/log/redmine/unicorn.stdout.log"
preload_app true
check_client_connection false
run_once = true
before_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
if run_once
run_once = false # prevent from firing again
end
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
File config.ru : the solutions I found that modified this file did not work so I rollbacked my modifications, it's the original onerequire ::File.expand_path('../config/environment', __FILE__)
run RedmineApp::Application
File /etc/redmine/config/application.rb : I've added the following line (between the ...)module RedmineApp
class Application < Rails::Application
...
...
config.assets.prefix = "/redmine/assets"
...
...
end
end
File /etc/redmine/config/environment.rb : I've added the following lines at the end of the file, after the Rails.application.initialize!Redmine::Utils::relative_url_root = "/redmine"
ActionController::Base.relative_url_root = "/redmine"
File /etc/redmine/config/routes.rb : I've only added the following line, at the beginning of the file. The other modifications I found on the web made the Redmine fail (404 or 500 error, or the launch fails)Redmine::Utils::relative_url_root = "/redmine"
File /etc/redmine/config/environments/production.rb : I've added the last line :Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.logger = nil
config.active_support.deprecation = :log
config.relative_url_root = "/redmine"
end
I'm aware that my modifications are a mix of different proposals I found on the web. I hope you'll be able to tell me what's wrong
Thanks !
Frederic
Replies (2)
RE: Redmine in a sub-URI, with nginx + Unicorn - Added by Frédéric MOULIS about 9 years ago
Forget about it, as no one answered to this, I found another way to have my redmine working (not in a sub-URI...)
RE: Redmine in a sub-URI, with nginx + Unicorn - Added by Jörg-Volker Peetz over 8 years ago
Hi Frederic,
a little late I, nonetheless, want to make some remarks. I have running Redmine in a sub-URI served by unicorn + nginx on my Debian system.
Only modifications I did in the redmine system is in file config/environment.db. The last three code lines of this file now read:
RedmineApp::Application.routes.default_scope = { :path => '/redmine' }
Rails.application.initialize!
Redmine::Utils::relative_url_root = '/redmine'
Additionally, this configuration needs a soft link in the working directory of redmine. AFAICS, in your case /etc/redmine/redmine -> .
I took some advise from Issue #11881#note-20 and the postings before it.
Regards,
Jörg-Volker.