Project

General

Profile

How to configure redmine with Apache to be accessible through an URL of type http://192.168.1.10/redmine ?

Added by Samax Tripwood almost 13 years ago

Hello,
For now, my Redmine is accessible with Mongrel through the URL http://ip_of_my_machine/redmine/, but CSS, images and links are broken.

I found that the base URL searched by Redmine is / and not /redmine, so all the links point on http://ip_of_my_machine/ instead of http://ip_of_my_machine/redmine/. That's the reason of why images, CSS and links doesn't works. But I didn't found any solution to resolve that problem, even after a long search on Google.

Here is my Apache config file for Redmine, if that can help:

# On paramètre le proxy pour transmettre les requêtes adresées à tracker.lan soient transmises à
# Redmine (Mongrel est installé en local sur le port 3000)
ProxyPreserveHost Off
ProxyPass        /redmine  http://127.0.0.1:3000/
ProxypassReverse /redmine  http://127.0.0.1:3000/

# On définit les fichiers de log
ErrorLog /opt/redmine/log/apache-error.log
CustomLog /opt/redmine/log/apache-access.log combined

I know that I can configure Apache to directly run Redmine with Passenger, but I didn't find how to configure Apache to act like I would want to (I only found how to configure it as a Virtualhost).

If that can help, I run the last SVN version of Redmine.

Thanks in advance for your answers.


Replies (4)

RE: How to configure redmine with Apache to be accessible through an URL of type http://192.168.1.10/redmine ? - Added by Andy Bolstridge almost 13 years ago

I think I added the how-to somewhere but here's what I did. FYI, the docs on passenger (http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_a_ruby_on_rails_application) were updated and do have this setup listed. The trick is a symlink to the static files.

gem install passenger
passenger-install-apache2-module
- setup a link to current version so upgrading is easier.
ln -s /home/webservices/ruby_apps/redmine-1.1.3/ redmine

- edit apache config
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/bin/ruby

- create a directory in apache config
<Directory>
/home/webservices/html/redmine
RailsBaseURI /redmine
AllowOverride all
Options -MultiViews
</Directory>

- create a link to the public files
ln -s /home/webservices/ruby_apps/redmine/public /home/webservices/html/redmine

so now you have a root directory that is a symlink to the files in the redmine directory, but the redmine directory lives in a totally different location - which is where passenger runs, so you get normal html and ruby-interpreted files run by 2 different systems appearing to be in 1 place.

RE: How to configure redmine with Apache to be accessible through an URL of type http://192.168.1.10/redmine ? - Added by Ivan Cenov almost 13 years ago

Hi,

Try with some variant of this line at the end of path_to_redmine/config/environment.rb:

Redmine::Utils::relative_url_root = "/redmine" 
or
Redmine::Utils::relative_url_root = "redmine" 
or
Redmine::Utils::relative_url_root = "redmine/" 
or
Redmine::Utils::relative_url_root = "/redmine/" 

If this does not help, the following is our configuration and I hope it would be in help of you:

Our Redmine is at http://redmine.mycompany.com (different from yours http://yourcompany/redmine).
Suppose that Redmine is located in the e:\data\redmine folder.

1) we have virtual host "redmine.mycompany.com":

<VirtualHost *:80>
    ServerName redmine.mycompany.com
    ServerAdmin admin@mycompany.com
    DocumentRoot e:/data/redmine/public
    DirectoryIndex index.html index.php

# httpd-proxy-mongrel.conf resides where virtual-hosts.conf resides.
# The original in SVN is in redmine folder and should be copied here.
    Include e:/data/vhosts/httpd-proxy-mongrel.conf

    ErrorLog e:/data/log/redmine.error.log
    TransferLog e:/data/log/redmine.transfer.log
</VirtualHost>

2) The contents of httpd-proxy-mongrel.conf is:
# Loading mod_proxy, mod_proxy_http and mod_proxy_balancer

<IfModule !mod_proxy.c>
    LoadModule proxy_module lib/modules/mod_proxy.so
</IfModule>
<IfModule !mod_proxy_http.c>
    LoadModule proxy_http_module lib/modules/mod_proxy_http.so
</IfModule>
<IfModule !mod_proxy_balancer.c>
    LoadModule proxy_balancer_module lib/modules/mod_proxy_balancer.so
</IfModule>

<Directory E:/data/redmine/public/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order deny,allow
    Deny from all
    Allow from 192.168.20
</Directory>

<Proxy *>
    Order Deny,Allow
    Deny from all
    Allow from 192.168.20
</Proxy>

ProxyPass / balancer://redmine_cluster/
ProxyPassReverse / balancer://redmine_cluster/

<Proxy balancer://redmine_cluster>
    BalancerMember http://redmine.mycompany.com:3001
    BalancerMember http://redmine.mycompany.com:3002
    BalancerMember http://redmine.mycompany.com:3003
</Proxy>

3) Next line have to put at the end of E:/data/redmine/config/environment.rb

Redmine::Utils::relative_url_root = "" 

4) Starting mongrel services:

mongrel_rails service::install -N mongrel_redmine_3001 -D "Mongrel serving Redmine on 3001" -p 3001 -e production -c e:\data\Redmine
mongrel_rails service::install -N mongrel_redmine_3002 -D "Mongrel serving Redmine on 3002" -p 3002 -e production -c e:\data\Redmine
mongrel_rails service::install -N mongrel_redmine_3003 -D "Mongrel serving Redmine on 3003" -p 3003 -e production -c e:\data\Redmine

RE: How to configure redmine with Apache to be accessible through an URL of type http://192.168.1.10/redmine ? - Added by Samax Tripwood almost 13 years ago

First, thanks for your answers both. I tried the Andy Bolstridge's solution and it worked for the application links, but the stylesheets and CSS still doesn't works...

When I try to manually enter the stylesheet url in firefox (http://localhost/redmine/stylesheets/application.css?1294219131), I obtain the following error:

No route matches "/stylesheets/application.css" with {:method=>:get}

And here is my Apache redmine config file:

<Directory /var/www/redmine>
    Options Indexes FollowSymLinks MultiViews  # For test
    AllowOverride None                         # For test
    Order allow,deny                           # For test
    allow from all                             # For test
    RailsBaseURI /redmine
    PassengerResolveSymlinksInDocumentRoot on
    PassengerAppRoot /var/www/redmine          # Doesn't works without it
</Directory>

Can someone help me solving this issue ?

RE: How to configure redmine with Apache to be accessible through an URL of type http://192.168.1.10/redmine ? - Added by Andy Bolstridge almost 13 years ago

I would get rid of all the stuff in your Directory except for what I showed you.
Make sure you have the PassengerRoot set in your global apache config (and PassengerRuby)

I don't have PassengerAppRoot set, and I definitively don't have the PassengerResolveSymlinksInDocument at all. I think that's probably what's causing your problem - the stylesheets are being interpreted as ruby code, not bypassed straight to apache.

Oh, and make sure you have Options MultiViews set in your Directory too. Note the ""

    (1-4/4)