File Uploads - Nextcloud

I have a couple of servers running on my network and use MiaB’s hidden reverse proxy feature so they are accessible outside of my network. One of these is a Nextcloud instance. It was all running really well on v57 and Ubuntu 18.04. I don’t do an awful lot with it but I do take the odd photo while out and about and they automatically get uploaded to Nextcloud.

When I originally set this up I had to search around to find out how to enable uploads because they always failed. The original answer I found was to edit etc/nginx/conf.d/local.conf and add two lines to the SSL section of the Nextcloud entry:

sendfile on;
client_max_body_size 0;

This was fine until the next day when MiaB did its update checks and reset this file. After searching around some more and looking at some of the MiaB files (and with a bit of trial and error) I managed to find another solution, which was to edit ~/mailinabox/management/ and add a couple of lines under these entries:

nginx_conf_extra += "\n\t\tproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;"
nginx_conf_extra += "\n\t\tproxy_set_header X-Forwarded-Host $http_host;"
nginx_conf_extra += "\n\t\tproxy_set_header X-Forwarded-Proto $scheme;"
nginx_conf_extra += "\n\t\tproxy_set_header X-Real-IP $remote_addr;"
nginx_conf_extra += "\n\t}\n"

The two lines I added were:

nginx_conf_extra += "\n\tsendfile on;"
nginx_conf_extra += "\n\tclient_max_body_size 0;\n"

This has all been working really well but, and I’m not sure if this is a change introduced in v61 or whether it was in v60 too and I hadn’t noticed, it’s now back to resetting the file every day and every morning after I change it back I get an email saying:

web updated

I’m trying to work out if the updater has changed or is broken or whether there’s a better way of doing it in MiaB, so I’m hoping someone here may have a solution.

Have you looked at the code around line 210 of management/ It may allow what you’re trying to do by including a conf file that you create:

        # Add in any user customizations in the includes/ folder.                                                                                                                                                                    
        nginx_conf_custom_include = os.path.join(env["STORAGE_ROOT"], "www", safe_domain_name(domain) + ".conf")
        if os.path.exists(nginx_conf_custom_include):
                nginx_conf_extra += "\tinclude %s;\n" % (nginx_conf_custom_include)

Thanks for the reply. I think I did vaguely notice it previously when trying to resolve the issue but, as my solution worked on the older version, didn’t give it much of an afterthought. I’m not entirely sure I’d know how to format an extra config file. Is it as simple as just adding something like:

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;


        sendfile on;
        client_max_body_size 0;

The include happens within the server directive scope for the domain, so your config file blah.blah.conf, only needs the two lines:

        sendfile on;
        client_max_body_size 0;

Thanks again. Simple as that eh …

One (hopefully) final question:

As there doesn’t seem to be a pre-existing includes folder, can I just check where it’s supposed to go? I’m guessing either /etc/nginx/conf.d/includes or /home/user-data/www/includes?

I’m also guessing that the conf file should be named for the subdomain I’m trying to get this working on ( to use my above example?

OK, that was two questions :slight_smile:

Quoting myself, neither of these locations appear to work as I’m still getting:

Upload failed - Request Entity Too Large

Yeah, gray area in terms of naming, support, and documentation. It’s actually the top-level www directory, typically /home/user-data/www

If you set up you’ll see this directory gets created: /home/user-data/www/
Then just add your server-block custom file next to it, i.e.: /home/user-data/www/
And get the web service to restart.

Perfect. That worked. Thanks for the help :+1: