Settings for Nginx reverse Proxy in front of Nginx/Nextcloud installation

Hi I currently have a running and working installation of Nextcloud(18.3) and nginx running within a FreeBSD jail within a FreeNAS installation 11.3U3.

Additionally I have another Arch Linux VM running on FreeNas running nginx as a reverse proxy for my LAN.

I’ve yet to “link” the nginx reverse proxy and Nextcloud/nginx installation. I additionally use Cloudflare for my DNS records.

My question is regarding how to configure the reverse proxy to “proxy pass” to the upstream Nextcloud/nginx installation. What headers do I need to pass from the nginx reverse proxy to nginx nextcloud (if any)? I’m fairly familiar with working with SSL certs, and my intention is to terminate the SSL at the reverse proxy but then re-encrypt to the nginx/nextcloud upstream installation. I have LE certs which are different for both the reverse proxy and nginx/nextcloud installation – I don’t think I need any help on configuration of the SSL certs – only to the extent if they change the headers that might need to be passed.

Additionally since I’m using CF, I’m aware CF is also a “proxy” and I’m not sure if this changes anything with my installation as well.

Thanks.

I’d be interested in a solution too. Have you ever figured this out?

Yea I did finally figure this out (I think). I haven’t battle tested the configuration, but I did manage to put a nginx reverse proxy in front of the nginx/nextcloud installation. There is actually a lot of detail to get this to work, since it kind of depends how you set up php-fpm, and actually wrote your nginx.conf files. What have you tried?

You did? Congratulations! I’d be really interested in your config files.

So far, I tried to work with a couple of guides to setup nginx. There’s this guide in particular, which helped me setup my TrueNas Core system. And that worked pretty well. I assumed, the same setup worked on ubuntu too, but unfortunately that’s not the case.

I’m using a LE wildcard cert and would like to what goes in the nginx.conf, nextcloud.conf and config.php (in Nextcloud). I’m on ubuntu server 22.04, NC25 and php 8.1. Also I use the same nginx as a db server for nc and my non-functional reverse-proxy.

So a typical installation of nextcloud actually uses nginx (or apache) as a webserver which server nextcloud since nextcloud is written using php. All nginx can serve as a reverse proxy, in a standard installation nginx is just the webserver. I’m using a second nginx on a separate VM as my reverse proxy forwarding to nginx/nextcloud.

In terms of needing help on your setup, you really need to provide a lot more details. Not linking to the guide you referenced and showing any of your config files doesn’t really help me a ton. I used the standard nginx as a template to start with: NGINX configuration — Nextcloud latest Administration Manual latest documentation. Please provide some more details and I’d be happy to help

Yes, you’re right. It was late when I posted the other answer and forgot to link to the guide I mentioned. This time, I used Xiao’s guide, which is simple to setup and works absolutely flawless.

In another thread, I was looking for help, somebody pointed me to the fact, that in my setup I don’t need to reverse proxy Nextcloud, only the other servers (Navidrome in my case).

I’m now using Xiao’s navidrome.conf (+ssl directives) and it works as long as I mute my Navidrome conf. If the navidrome.conf is not muted, the Nextcloud url also points to Navidrome. I guess (hope) that a small instruction in either conf file could solve this.

(I don’t post my Nextcloud config.php since I’m sure now it is a nginx and not a Nextcloud issue).

P.S.: I think I’ve solved it myself by just deleting “default server” out of the navidrome.conf and “voilà” it works. Thanks for your input.