Hosted on home internet connection - bandwidth optimization

I am using nextcloud hosted on my home internet connection running on a raspberry pi. There’s a domain name (cloud.maniarfamily.com) that I’ve routed using DNS to the WAN interface of my home router. I’ve added to only this external domain to trusted domains list in the conf file of NextCloud.

I’ve configured this domain on all systems using nextcloud (mobile, laptop, PC). However, this is inefficient from bandwidth utilization point of view. As my mobile / laptop / PC at home send data to the raspberry pi which hosting nextcloud inside the network by routing it outside and bringing it back inside.

For example a 5 MB file when uploaded shows as 5 MB upload for my mobile phone and 5 MB download for my nextcloud totaling to 10 MB.

Hence my question, is there a way I can configure the internal IP of raspberry pi to the same account so that when I’m on my home network the upload takes place directly to the nextcloud server without being routed outside the home network. Also, for the same account when I’m outside my home network, the upload takes place via internet?

Nextcloud version : 14.0.3
Operating system and version : RASPBIAN STRETCH LITE
Apache 2.4.25 (Raspbian)
PHP 7.0.30-0+deb9u1

The output of your Nextcloud log in Admin > Logging:
There are no errors except login failure (possible bruteforce / password guessing attempts).

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'redacted',
  'passwordsalt' => 'redacted',
  'secret' => 'redacted',
  'trusted_domains' =>
  array (
    0 => 'cloud.maniarfamily.com',
  ),
  'datadirectory' => 'redacted',
  'dbtype' => 'sqlite3',
  'version' => '14.0.3.0',
  'overwrite.cli.url' => 'http://172.16.xx.xx/nextcloud',
  'installed' => true,

The output of your Apache/nginx/system log in /var/log/____:

** NOT REQUIRED, HENCE NOT PASTED **

I don’t know why some routers are doing it. What you can do is to use your own DNS resolver on your network (e.g. you can install unbound on your raspbi), you can tell to resolve your cloud-hostname to the local ip of your setup, e.g. cloud.myfamily.com -> 192.168.2.2.

Some routers with open software (dd-wrt, …), you can do this on the router itself.