Edit NextCloud config file:
sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php
Add the trusted proxies configuration. The first one is your local reverse proxy address (for example Nginx Proxy Manager), the rest are CloudFlare’s IP ranges:
'trusted_proxies' =>
array (
0 => '10.220.2.1',
1 => '173.245.48.0/20',
2 => '103.21.244.0/22',
3 => '103.22.200.0/22',
4 => '103.31.4.0/22',
5 => '141.101.64.0/18',
6 => '108.162.192.0/18',
7 => '190.93.240.0/20',
8 => '188.114.96.0/20',
9 => '197.234.240.0/22',
10 => '198.41.128.0/17',
11 => '162.158.0.0/15',
12 => '104.16.0.0/13',
13 => '104.24.0.0/14',
14 => '172.64.0.0/13',
15 => '131.0.72.0/22',
16 => '2400:cb00::/32',
17 => '2606:4700::/32',
18 => '2803:f800::/32',
19 => '2405:b500::/32',
20 => '2405:8100::/32',
21 => '2a06:98c0::/29',
22 => '2c0f:f248::/32',
),
You can find an updated list of CloudFlare’s IP ranges here: