Content
Reverse proxy and link generation
Added by Taras Zakharko over 10 years ago
Dear all,
I am currently trying to set up OpenProject on our server. For a number of reasons, I have my OpenProject+Passenger installation on a virtual linux machine (Debian). The VM is connected to a host-only virtual network and everything works wonderfully when the the website is accessed directly from the host. Now, to make it accessible to other clients, I am using a apache reverse proxy, something like this:
ProxyPass /projects http://projectsvm
ProxyPassReverse /projects http://projectsvm
Where projectsvm is the server-local virtual IP of the VM.
Now, this works, but unfortunately, OpenProject does not seem to be ok with the fact that is hosted via /projects. E.g. the links it generates are something like ‘server/login’ instead of ‘server/projects/login’. I tried fiddling around with rails_relative_url_root, but his only changes the links generated for the assets. Those also work in a weird way, e.g. /projects/assets/application-142f200494da18550f6a1573be06405b.js is accessed without any problems, but the similar link for the css does not work. At the same time, other generated links (e.g. for login window etc.) again lack the prefix.
I am very new to server configuration so its all quite confusing. I guess what I am looking for is a way to tell Passenger or OpenProject that my installation is accessible via the prefix /projects so that all links are generated correctly. Is there a way to do this?
Thank you!
Replies (5)
Hello Taras,
I must admit that I’m not sure about the following myself but as your problem sounds pretty much like subdirectory deployment it might be worth a try: Additionally to changing the
rails_relative_url_root
I find the following in the virtual host file:You find more detailed information in the passenger documentation about Deploying to a sub URI.
I hope this information helps?
Kind regards,
Hagen
Hi Hagen,
thank you for your answer! Unfortunately, I am not deploying Passenger via Apache - I am using the Standalone version in a virtual machine and then redirecting my main Apache server to this machine. You can think about it as having a dedicated machine only for OpenProject (running Passenger Standalone) behind a firewall and redirecting my main webserver to this box via a forward/reverse proxy.
The rails_relative_url_root works quite well for links OpenProject generates to find assets, but its not added to the website links like ‘login’, ‘projects’ etc. Unfortinately, I am a total noob when it comes to Ruby and Ruby on Rails. I think there is a way to modify routes.rb to add the prefix to every link (hard-coding it would be perfectly fine), but I have no idea how to go about this…
Alternatively, I can of course install Apache within my VM and try to work from there, but that would be a waste, I believe (essentially, I’ll be running 3 web servers behind each other).
Best,
Taras
Hi Taras,
there is another option, though it isn’t recommended: You can scope the routes (see the second bullet on the page linked) in
config/routes.rb
.This is not a recommended approach because
But it might work.
Kind regards,
Hagen
Hi Hagen,
I just managed to fix my problems by using Thin instead of Passenger. It has this neat ‘—prefix’ option which does exactly what I wanted. Its strange that Passenger does not seem to support this…
Thank you for your help!
— Taras
Hi,
I had a similar problem: OpenProject running inside a Docker container using Passenger and Nginx, which I wanted to deploy publicly via Apache at a subdir URI (using SSL). Here is what I did:
configuration.yml
and setrails_relative_url_root
to"/subdir"
./home/app/openproject
, this is my configuration file:Note that it is important to repeat
passenger_enabled on
inside thelocation
directive.RAILS_ENV=production bundle exec rake assets:precompile
again.After restarting Nginx, OpenProject should be available and working at
https://localhost:3000/subdir
. This may not be required, but since I’m using HTTPS, in Administration > Settings > General, I’ve set Protocol to HTTPS.Then, configure Apache on the host to act as a reverse proxy:
Now, OpenProject is available and working at
https://mydomain.com/subdir
.Having the public interface and the internal site use the same protocol (HTTPS in my case) and the same path (
/subdir
) was critical to have this work seamlessly.Hope this helps!