Defect #13077


redirect to wrong back_url behind Apache reverse proxy

Added by Mathias Walter about 11 years ago. Updated about 6 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:
Affected version:


I've configured my Apache proxy exactly as described in but Redmine redirects to a wrong URL by removing the path "/redmine". Hence, I cannot login and use the system. It works well with the local domain.

That happens after migration from 1.4 to the latest version 2.2.2 and seem to be independent of the 'Settings->General->Host name and path'.

It does not help either, if I change the environment.rb and set any combination of Redmine::Utils::relative_url_root or ActionController::Base.relative_url_root.

I also tried to enable/disable the browsers referer options but it didn't help.


Rails 3.2.11
Ruby 1.9.3-p374
Redmine 2.2.2 r11293

Settings->General->Host name and path:


Proxy config:
ProxyPass /redmine http://localserver:3000/
ProxyPassReverse /redmine http://localserver:3000/

Now, the requested URL

changes to

Related issues

Related to Redmine - Defect #12102: Installed Redmine in a sub-URI: Links are generated not correctlyNew

Actions #1

Updated by Mathias Walter about 11 years ago

The internal web server was used and redmine was started with ./script/rails server -e production

log entry:

Started GET "/" for at 2013-02-04 15:02:33 +0100
Processing by WelcomeController#index as HTML
  Current user: anonymous
Redirected to http://subdomain.domain.tld/login?back_url=http%3A%2F%2Fsubdomain.domain.tld%2F
Filter chain halted as :check_if_login_required rendered or redirected
Completed 302 Found in 6ms (ActiveRecord: 1.5ms)
Actions #2

Updated by Mathias Walter about 11 years ago

I've updated from Redmine 1.2, not from 1.4.

Actions #3

Updated by Etienne Massip about 11 years ago

  • Status changed from New to Closed
  • Priority changed from Urgent to Normal
  • Resolution set to Invalid

This is mostly support request, neither a bug or feature request.

Configuring Redmine on a relative root is a bit tricky with Redmine 2.x and you have to define a scope for routes.

Basically, adding RedmineApp::Application.routes.default_scope = '/redmine' should help you, see #12102#note-1.

Actions #4

Updated by Mathias Walter about 11 years ago

Just for the records:

Since I didn't get it to work with the internal Webrick server (even if I set RedmineApp::Application.routes.default_scope), I switched to Thin and changed the configuration according to Teddy's comment (#12102-12) and with config.asset_path = '/redmine%s'.

Then I gave Puma a try. Unfortunately, Puma does not support a prefix parameter. Hence I changed the according to #12102-13.

Now it works like a charm.

The wiki document HowTo_Install_Redmine_in_a_sub-URI whould be updated to Redmine 2.x configuration.

Actions #5

Updated by Anonymous over 10 years ago

I had the same problem. To reproduce this:

  1. Sign in
  2. Click the sign out. This should produce a URL like this: http://domain.tld/login?back_url=http%253A%252F%252Fdomain.tld%252F
    1. Notice that the back_url is essentially escaped twice.
  3. Sign in again. You are now authenticated according to the logs but the redirect fails and you don't go anywhere
  4. Refreshing the page brings you to the default page (my_page_path)

A simple fix for this was to unescape twice the back url in ApplicationController::redirect_back_or_default. Change
back_url = params[:back_url].to_s
back_url = CGI.unescape(CGI.unescape(params[:back_url].to_s))

Actions #6

Updated by Ryan J almost 10 years ago

This is possibly an Apache issue. I have no idea how to make it work properly though.

Explanation from Atlassian
Possibly related Apache bug

Actions #8

Updated by Aleksandar Pavic about 6 years ago

This is still issue, I am on Redmine 3.4 configured running behind IIS as reverse proxy, on PUMA...


Also available in: Atom PDF