This article will walk you through setting up Apache to serve up redmine in a subdirectory over an SSL connection. It will use thin as the application server.
Let me start off by saying, what a pain in the ass. I fought with this for over an hour, trying to get everything to work correctly.
- Running on my SSL site, which is running Apache and protected by client certificates.
- Running under the
/redminesubdirectory on that site.
- Served by Thin, running as my Apache user, and proxied by Apache
The real problem I encountered with this setup, after following all the usual guides I could find, was that when trying to access Redmine via
/redmine, it would redirect to
/login, rather than
/redmine/login. Static assets also failed to load. Fortunately, this guide will tell you how to fix both.
Getting it all to work:
Here’s an overview of what we’ll be doing:
- Install Thin
- Set up Thin as a system service, and generate a configuration to serve up Redmine
- Configure Redmine and Thin so they know we want to serve up pages under
/redmine, and not
- Configure Apache to proxy the requests to the Thin instance.
The first step is to install Thin and get that up and running. To do this, open up your Redmine
Gemfile and add this to the bottom:
sudo bundle install
to get Thin installed. You can omit the sudo if your ruby is managed via rvm, or otherwise installed somewhere your user has write access to.
Next, we need to install Thin as a system service. To do this, just run
and follow the distro-specifics for getting it to start at boot. This also requires creating a config file for your redmine install. Thin makes this easy:
thin config -C /etc/thin/redmine-2.2 -c /var/www/redmine-2.2 \ -u www-data -g www-data -e production --prefix=/redmine
What’s all that shit mean?
- -C specifies the output filename for the config file
- -c specifies the directory to change to when starting
- -u / -g set the user and group that thin will run as
- -e specifies the rails environment.
- –prefix tells thin that it needs to prefix all url paths with
/redmine. This is the solution to the first problem above; where it would redirect
If you want, you can edit the file created by that command and edit anything. It’s YAML.
Go ahead and start up thin via the system service:
sudo /etc/init.d/thin start
Next, we need to tell Redmine that it will be serving its assets (CSS and JS, images, etc) from
/redmine, and not
/. To fix this, open up the file
config/environment.rb and all this line to the bottom of it:
Redmine::Utils::relative_url_root = "/redmine"
Optional Test the configuration up to this point. This is pretty simple; (assuming you’re using SSH) just forward a local port to port 3000 (the default; if you changed it, use that port) and load it up in your browser. Trying to request / should give you an error. Requesting /redmine should give you a Redmine login.
Provided that everything is working OK from the test above, now it’s time to setup Apache to proxy the connection to the Thin instance running on the machine. Open up your Apache VirtualHost config and add the following Location block:
ProxyPass http://localhost:3000/redmine/ ProxyPassReverse http://localhost:3000/redmine/
sudo apachectl restart
That’s all there is to it! Now, you should be able to browse to your VirtualHost’s /redmine and see your login page. Please leave any questions in the comments.