Content
OpenProject Docker behind an NGINX Reverseproxy
Added by Michael Kelly almost 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:
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)
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:
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:
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!
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.
David w. wrote:
Have you set the host name in OpenProject (Administration -> System)?
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..
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.
I believe I have configured my proxy as per your docs... please see https://community.openproject.org/work_packages/42943#activity-3 thanks
I can see in that work package you're doing the following:
proxy_set_header X-Forwarded-Host $http_host;
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..
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".
Any chance of getting a copy of your nginx host config? the one in /etc/nginx/sites-available
I fixed it via sub_filter on nginx.. though this is a bandaid on some poor code..