Project

General

Profile

Help with setting up Redmine with Passenger as proxy to an HTTP server sitting on a distinct host

Added by Paul Belanger over 7 years ago

Team,

I have a Redmine VM that runs fine when hitting the URL directly; it renders as expected.
When I configure my HTTP server behind which I would like to hide the dedicated VM through proxy, the contents displayed is not rendered correctly.
I'm sure I goofed something silly somewhere on my web server or on the Redmine server.

Here's the configuration of the HTTP server that invokes the remote-served Redmine:

(...)
<Location /redmine>
ProxyPass http://xxx.yyy.zzz.139/
ProxyPassReverse http://xxx.yyy.zzz.139/
</Location>
(...)

And here's the remote HTTP host configuration, which hosts the Redmine stack:
(...)
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/opt
PassengerRoot /opt/bitnami/ruby/lib/ruby/gems/2.1.0/gems/passenger-5.0.6
PassengerRuby /opt/bitnami/ruby/bin/ruby
RailsBaseURI /redmine
<Directory /var/opt/redmine>
Option FollowSymLinks
Allow from all
Options -MultiViews
Require all granted
RailsBaseURI /redmine
PassengerResolveSymLinksInDocumentRoot on
</Directory>
</VirtualHost>
(...)

Stack:
------
Apache 2.4.20
Ruby 2.1.9p490
Passenger

I made a symlink between the Public folder (as was recommended on some site) and a new location, for broadcast:
%>ln -s /opt/bitnami/apps/redmine/htdocs/public /var/opt/redmine

My Redmine assets are not correctly resolved - and I can't seem to figure the right proxy/reverseproxy syntax.

Any idea?


Replies (9)

RE: Help with setting up Redmine with Passenger as proxy to an HTTP server sitting on a distinct host - Added by Martin Denizet (redmine.org team member) over 7 years ago

If I understand correctly, your proxy is at domain.com/redmine and your Redmine actually lives at myprivateredmine.com/redmine.
The assets probably wont load because they are referred at myprivateredmine.com/redmine/ which is not directly accessible.
If that's the case, I suggest that you need to inform the Rails app that its public URL is domain.com/redmine and not myprivateredmine.com/redmine.
Check this: http://stackoverflow.com/questions/2660172/how-do-i-set-default-host-for-url-helpers-in-rails
The Host name and path section of the settings could also be relevant.
Cheers,

RE: Help with setting up Redmine with Passenger as proxy to an HTTP server sitting on a distinct host - Added by Paul Belanger over 7 years ago

Thanks for the quick reply, Martin.

You read that correctly - I have 2 distinct servers (one which is exposed and the other which is a backend).
I don't remember having had to configure any action controller on an earlier setup I did, so I'm a little perplexed with my current issue - but then again, it's been almost 1 year I've actually spent time around that application.

Do I perform the configuration of "default_url_options" in the environment.rb file:

Rails.application.routes.default_url_options[:script_name]='/redmine'

... or somewhere else?

RE: Help with setting up Redmine with Passenger as proxy to an HTTP server sitting on a distinct host - Added by Martin Denizet (redmine.org team member) over 7 years ago

I'd try to put

config.action_controller.default_url_options[:host] = 'myprivateredmine.com'

In config/environments/production.rb
Not 100% positive it's the correct parameter.
You might also try
Rails.application.routes.default_url_options[:host] = 'myprivateredmine.com'

Need to restart Apache afterwards obviously.
Let me know if that solves the issue.
Cheers,

RE: Help with setting up Redmine with Passenger as proxy to an HTTP server sitting on a distinct host - Added by Martin Denizet (redmine.org team member) over 7 years ago

Did you also setup correctly the hostname in the settings? In my example it would be domain.com.

Fixed. - Added by Paul Belanger over 7 years ago

Would love to reply, but I kept getting an error 500 on this forum.

More about the fix - Added by Paul Belanger over 7 years ago

I kid you not, I can't provide information about the 2-step process.

It's really simple... - Added by Paul Belanger over 7 years ago

Step 1.
Edit the "environment.rb" file located at "/opt/bitnami/apps/redmine/htdocs/config" to add:

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

Step 2 - add the reference on the front-end server for the back-end server - Added by Paul Belanger over 7 years ago

Step 2.
Configure the front-end HTTP server to reach the new back-end location.

Step 2.1 - add a Location on the front-end (web) server - Added by Paul Belanger over 7 years ago

Edit the httpd.conf file for your Web server
Add:

<Location /redmine>
  ProxyPass http://backend/redmine
  ProxyPassReverse http://backend/redmine
</Location>

    (1-9/9)