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. OpenProject Docker behind an NGINX Reverseproxy

OpenProject Docker behind an NGINX Reverseproxy

Added by Michael Kelly over 3 years ago

Hi Guys,

we would Test OpenProject within our Company (maybe when this is successfull we switch to Enterprise) and i have a Problem:

Environment:

  • Nginx Reverseproxy (https://ngrp.com)
  • OpenProject Installation via the official Dockerhub Container (Port 8000) IP: 10.0.0.1

If i Access OpenProject directly (http://10.0.01) it works perfectly. But i must publish the Application behind the following URL for the Users:

  • https://ngrp.com/openproject

to achieve that i made the following NGINX Configuration:

  location /openproject/ {
   proxy_pass             http://10.0.0.1:8000/;
   include                /etc/nginx/conf.d/proxy.conf;
 }

But when i open the page through the Reverseproxy, the Webbrowser displays only a White Page.

In the Webbrowser Debugger i see, that some paths are wrong. Example: 

https://ngrp.com/assets/frontend/styles.c3a5e7705d6c5db9cfc1.css

but because the Subsite-Config in the NGINX it should be:

https://ngrp.com/openproject/assets/frontend/styles.c3a5e7705d6c5db9cfc1.css

So can somebody please tell me, which configuration is needed, so i can Openproject under the URL https://ngrp.com/openproject/ successfully?

Thank you very much.


Replies (12)

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by Markus Kahl over 3 years ago

Hey,

if you want to use OpenProject under a subdirectory you have to consider this both in the proxy configuration and also configure it in the environment of the container. Here's our docs section for that topic: https://www.openproject.org/docs/installation-and-operations/installation/docker/#2-location-subdirectory

You have to add the following to the container's environment:

OPENPROJECT_RAILS__RELATIVE__URL__ROOT=/openproject
OPENPROJECT_RAILS__FORCE__SSL=true

Without the first line the assets won't be found which is exactly the problem you are running into.
The second line is to ensure OpenProject uses strict transport security and secure cookies even though the requests to OpenProject itself are coming via http from the proxy.

The docs are showing the configuration for Apache but the nginx config can be derived from that.
You already have the proxy pass itself, but you should also set some headers to make sure everything works correctly:

proxy_set_header  X-Forwarded-Proto https;
proxy_set_header  X-Forwarded-Ssl on;
proxy_set_header  X-Forwarded-Host $http_host;

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by David w. over 3 years ago

Hey, 

i dont know exactly if my Problem is like yours but it sounds linke it. Im trying to run OP on my NAS with Docker and the NAS has its own Reverse Proxy System. I set up OP and im able to reach it via IP and its set Port. Now im using the Reverse Proxy from my NAS to redirect from the Web to NAS and NAS to Docker/OP. Im able to Connect to OP but every single Button i press is redirecting to the local IP:Port. I had a similar problem with my Nextcloud setup were i had to set -e OVERWRITEHOST=myURL.com. Is there anything like this in OP?

btw I can reach out to every single page by copying the IP:PORT"/path/" to the URL:PORT"/path/".

Thanks!

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by Connor Moroney over 3 years ago

I just use NGINX Proxy manager running in a separate docker.  The thing works great and pretty much does all its configuration on its own.

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by Markus Kahl over 3 years ago

David w. wrote:

Hey,

i dont know exactly if my Problem is like yours but it sounds linke it. Im trying to run OP on my NAS with Docker and the NAS has its own Reverse Proxy System. I set up OP and im able to reach it via IP and its set Port. Now im using the Reverse Proxy from my NAS to redirect from the Web to NAS and NAS to Docker/OP. Im able to Connect to OP but every single Button i press is redirecting to the local IP:Port. I had a similar problem with my Nextcloud setup were i had to set -e OVERWRITEHOST=myURL.com. Is there anything like this in OP?

btw I can reach out to every single page by copying the IP:PORT"/path/" to the URL:PORT"/path/".

Thanks!

Have you set the host name in OpenProject (Administration -> System)?

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by bret watson almost 3 years ago

I see the same problem as @david w. - many URLs for OP are set to absolute paths - even though they should be relatives.. eg: they are http://internal.web.server/projects/openproject/work_packages  instead of /projects/openproject/work_packages this makes it incredibly hard for a reverse proxy to deal with things.. any change of a fix?

Expanding on this - I note that "My page" is a relative link, but "My Account" is an absolute link and "Sign out" is a relative link, Links to projects are relative, but links to things like work packages etc within a project are all absolute - so frankly this is pretty shitty coding..

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by Markus Kahl almost 3 years ago

The fix is to configure the reverse proxy correctly.

You can find examples for reverse proxy configurations both for packaged and docker-based installations in our docs.

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by bret watson almost 3 years ago

I believe I have configured my proxy as per your docs... please see https://community.openproject.org/work_packages/42943#activity-3 thanks

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by Markus Kahl almost 3 years ago

I can see in that work package you're doing the following:

 proxy_set_header Host <internal host>;
 proxy_set_header X-Forwarded-Host $host:$server_port;
  1. Please try removing the Host header altogether, especially since it's pointing to the internal rather than the external host.
  2. Remove the port from the forwarded host (unless you access the proxy on a port other than 80), making this: proxy_set_header X-Forwarded-Host $http_host;

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by bret watson almost 3 years ago

I commented out proxy_set_header Host. I access the proxy on https so didn't change the server port..

No effect - the host name is still hard coded in the source page instead of relative links.. dug into the code and I can see where it is displayed, but still working out where the array is created..

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by David w. almost 3 years ago

I did a fresh install with Nginx Proxy Manager. My Problem was that all settings for https were reset after I requested a new ssl certificate. I had to check all boxes again and it worked. No env vars or additional settings in NginxPM. The only thing I had to do is passing the domain without "https://" into the settings tab in OP like "my.domain.org". Im using "openproject/community:12".

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by bret watson almost 3 years ago

Any chance of getting a copy of your nginx host config? the one in /etc/nginx/sites-available

RE: OpenProject Docker behind an NGINX Reverseproxy - Added by bret watson almost 3 years ago

I fixed it via sub_filter on nginx.. though this is a bandaid on some poor code..

location /openproject/ {

        proxy_set_header Accept-Encoding ""; # no compression allowed or next won't work

        sub_filter "http://<internal host>/" "https://<external host>/";
        sub_filter_once off;

        proxy_set_header Host <internal host>;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $host:$server_port;

        proxy_pass http://<internal host>/openproject/;

}
  • (1 - 12/12)
Loading...