• Post last modified:May 19, 2020
  • Post Comments:3 Comments

Additional Configuration for Nextcloud in NGINX Proxy Manager

Introduction

If you followed my previous posts on configuring reverse proxies in the NGINX Proxy Manager container using Cloudflare and your own domain or the free Duck DNS service, you may have noticed your subdomain for the Nextcloud application still not working after following the outlined steps.

This is a recognized issue within NGINX Proxy Manager and stems from the application not supporting the ability to forward to an HTTPS backend or server.

Luckily there’s an easy workaround we can make until it is updated to support the functionality we need.

Editing Nextcloud’s Configuration File

Navigate to the application configuration/installation folder for NGINX Proxy Manager within your operating system and navigate to the “proxy_host” folder within the “nginx” folder.

If you’re using Unraid, the folder path will look something like the one below:

/mnt/user/appdata/NginxProxyManager/nginx/proxy_host/

Open the folder and you’ll find a list of CONF files that are titled with what seem to be random numbers. Each of these files corresponds with the subdomains/proxy hosts you have set up within NGINX Proxy Manager – when a record is created, the application creates a CONF file for the record and stores it in this folder.

Open each CONF file until you find the corresponding file for Nextcloud. (In the screenshot above, “2” was the Nextcloud CONF file for me.)

Within the Nextcloud CONF file, find the following line:

include conf.d/include/proxy.conf

and replace it with the following:

add_header       X-Served-By $host;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto  $scheme;
proxy_set_header X-Forwarded-For    $remote_addr;
proxy_pass       https://$server:$port;

Save the CONF file and restart the Docker container.

Conclusion

The reverse proxy for Nextcloud should work properly after restarting the NGINX Proxy Manager container.

Note that every once in a while this configuration may be overwritten and the CONF file will need modified to re-enable the reverse proxy. The steps to do so will be the same as outlined above.

If you’re still experiencing issues or have any questions or feedback, feel free to leave a comment below.

Enjoy!

If you’ve found this or any of the other posts on SHIFT14 helpful, please consider supporting the site through a one-time PayPal donation or ongoing support through Patreon. My goal is to continue providing in-depth guides for the technical community and the support helps justify the time and resources spent doing so.

This Post Has 3 Comments

  1. SamuelQWE

    I’ve been able to set up other subdomains with NGINX Proxy Manager + Cloudflare just fine using your other guide. However, after following the outlined steps here, I can get my Nextcloud subdomain to load the page, but the parts of the page are missing. For one, I can’t even login since there is no login form, just a blank page with the next cloud logo and background.

    I’ve tried changing the configuration in the Nextcloud LinuxServer container according to SpaceInvaderOne’s video on using Nextcloud with a reverse proxy, but that makes no difference. I’ve also tried toggling between proxied and DNS only on Cloudflare, but I was only able to get the page to load with the proxied setting, and still with no login form.

    Did you require any additional configuration with your Nextcloud container, or did you use a different than the LinuxServer one?

  2. SamuelQWE

    It seems I have figured out the problem!

    I have Cloudflare’s Rocket Loader enabled, but it seems to be incompatible with Nextcloud. So to fix the issue, I created a page rule to exempt my Nextcloud subdomain from these types of optimization tools.

    After adding the page rule, everything works as expected. Just thought I would let people know in case they have a similar issue.

    1. Griffin

      Thanks for sharing! I’m not actually familiar with Cloudflare’s Rocket Loader – sounds interesting and definitely worth looking into.

Leave a Reply