Access over both LAN and domain

Nextcloud version (eg, 20.0.5): 26.0.0
Operating system and version (eg, Ubuntu 20.04): TrueNAS 13.0 U4
Apache or nginx version (eg, Apache 2.4.25): Apache, unsure how to check version
PHP version (eg, 7.4): 8.1.13

The issue you are facing:
By removing 'overwriteprotoco' => 'https' from config.php, I can access my Nextcloud server through LAN but I get an infinite login loop over the domain it is connected to (via cloudflare tunnelling)
By adding it, it works fine over the domain but does not connect through LAN ip saying “This page isn’t redirecting properly”

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Add or remove the flag from config.php
  2. Try accessing through LAN IP
  3. Try accessing through domain

do you have some more information for us?

The main problem maybe the server settings but there are no infos if you are connecting through reverse proxy etc. or which browser you use for testing.

e.g. Firefox → How to Fix "The Page isn't Redirecting Properly" Message? - MyThemeShop

have you also set other config.php parameters such as

Sure only ideas for the moment …