Top Menu

Jump to content
Home
    Modules
      • Projects
      • Activity
      • Work packages
      • Gantt charts
      • Calendars
      • Team planners
      • Boards
      • News
    • Getting started
    • Introduction video
      Welcome to OpenProject Community
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Enterprise support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Forgot your password?

      or sign in with your existing account

      Google

Side Menu

  • Overview
  • Activity
    Activity
  • Roadmap
  • Work packages
    Work packages
  • Gantt charts
    Gantt charts
  • Calendars
    Calendars
  • Team planners
    Team planners
  • Boards
    Boards
  • News
  • Forums

Content

Support Installation & Updates
  1. OpenProject
  2. Forums
  3. Support Installation & Updates
  4. Reverse proxy and link generation

Reverse proxy and link generation

Added by Taras Zakharko about 11 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)

RE: Reverse proxy and link generation - Added by Hagen Schink about 11 years ago

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:

Alias /projects /path/to/openproject

<Location /projects>
  PassengerBaseUri /projects
  PassengerAppRoot /path/to/openproject
</Location>

You find more detailed information in the passenger documentation about Deploying to a sub URI.

I hope this information helps?

Kind regards,
Hagen

RE: Reverse proxy and link generation - Added by Taras Zakharko about 11 years ago

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

RE: Reverse proxy and link generation - Added by Hagen Schink about 11 years ago

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

  1. OpenProject doesn’t support it,
  2. you have to “re-scope” the routes every time you update OpenProject.

But it might work.

Kind regards,
Hagen

RE: Reverse proxy and link generation - Added by Taras Zakharko about 11 years ago

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

RE: Reverse proxy and link generation - Added by Nicola Vitacolonna almost 11 years ago

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:

  1. In the container, edit configuration.yml and set rails_relative_url_root to "/subdir".
  2. In the container, configure an Nginx virtual host as explained at Deploying to a sub URI (as suggested in a post above, but for Nginx). Assuming that OpenProject is installed at /home/app/openproject, this is my configuration file:
server {
    listen 443 ssl;
    server_name localhost;
    ssl_certificate /etc/ssl/certs/openproject.crt;
    ssl_certificate_key /etc/ssl/private/openproject.key;
    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers RC4:HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    root /home/app/main; # Unrelated site, may be omitted

    # Deploy OpenProject at /subdir
    location ~ ^/subdir(/.*|$) {
      alias /home/app/openproject/public$1;
      passenger_base_uri /subdir;
      passenger_app_root /home/app/openproject;
      passenger_document_root /home/app/openproject/public;
      passenger_enabled on;
      passenger_user app;
    }

    passenger_enabled on;
    passenger_user app;

    passenger_ruby /usr/bin/ruby2.1;
}

Note that it is important to repeat passenger_enabled on inside the location directive.

  1. (Not sure if this is necessary) Run RAILS_ENV=production bundle exec rake assets:precompile again.
  2. Restart Nginx.

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:

<VirtualHost _default_:443>
        SSLProxyEngine on
        ProxyRequests Off
        ProxyPass /subdir https://127.0.0.1:3000/subdir

       <Proxy https://127.0.0.1:3000/subdir/*>
         Order deny,allow
         Allow from all
       </Proxy>

        <Location /subdir>
          ProxyPassReverse https://127.0.0.1:3000/subdir
        </Location>

        # Rest of virtual host configuration…
</VirtualHost>

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!

  • (1 - 5/5)
Loading...