Search code examples
apacheredminemod-proxy

Apache mod_proxy with Redmine on sub-URI


I must have read every single article on the internet regarding Redmine and Apache and I still cant get it to work!

I have Redmine running on http://server:3000 perfectly using Thin. We have another Apache service on the same server which hosts our internal web tools on a different port (8096) so I would like Redmine to follow the same convention.

In that respect on Apache in httpd.conf I've added:

ProxyPass /redmine http://127.0.0.1:3000/
ProxyPassReverse /redmine http://127.0.0.1:3000/
ProxyPreserveHost on

Which seems to work fine. If you type in http://server:8096/redmine it will bring up the Redmine start page, but clicking on any other link results is a 404.

It looks like its not appending the /redmine on links from the site as clicking on the 'admin' link takes me too http://server:8096/admin instead of http://server:8096/redmine/admin

I've also looked into adding any of the three below to config/environment.rb but there seems to be conflicting info on which to use, and none of them seem to:

ActionController::AbstractRequest.relative_url_root = "/redmine" 
ActionController::Base.relative_url_root = "/redmine" 
Redmine::Utils::relative_url_root = "/redmine" 

As always any help is greatly appreciated!

Edit::

I am also trialling out

ProxyPass /redmine http://server:3000
ProxyHTMLURLMap http://server:3000 /redmine
<Location /redmine>
    ProxyPassReverse http://server:3000
    SetOutputFilter proxy-html
    ProxyHTMLURLMap /               /redmine/
    ProxyHTMLURLMap /redmine/       /redmine
</Location>

but seems to have the same result. Interestingly, if I access http://localhost:8096/redmine from the local server all the links seems to work and direct to the correct page, except the CSS and JS is not working.

If remotely I manually type in any of the links http://server:8096/redmine/admin then I get the correct page with CSS etc, it's just the linking between pages that isn't working!


Solution

  • Man, I've never seen an working setup of apache proxy changing context like this:

    ProxyPass /redmine http://127.0.0.1:3000/
    

    This should work:

    ProxyPass /redmine http://127.0.0.1:3000/redmine
    

    To do that, you need to setup your backend server (mongrel or whatever) to work on a sub-uri.

    I would suggest you to use mod_passenger instead. This is the easiest way to setup redmine and it doesn't involve proxy. Here follows my setup:

    brunojcm@brunojcm-htpc:~$ cat /etc/apache2/sites-available/redmine 
    <Directory /var/www/redmine>
        RailsBaseURI /redmine
        PassengerResolveSymlinksInDocumentRoot on
    </Directory>
    

    Where /var/www/redmine is a link to your public redmine folder.

    brunojcm@brunojcm-htpc:~$ ll /var/www/redmine
    lrwxrwxrwx 1 root root 27 Sep  4  2011 /var/www/redmine -> /opt/redmine/current/public/
    

    You will also need to install mod_passenger. I don't remember exactly how to do it, but I believe you need to gem install passenger and after run passenger-install-apache2-module and follow the instructions.

    Hope it helps!