Unable to setup NGINX proxy for snap nextcloud - redirecting

I would like to setup Nginx reverse proxy on the server, but after setting vhost Nextcloud redirects me outside the proxy.

SNAP INSTALL: cloud.example.com:8443
Nginx vhost: cloud.example.com

server {
     listen      80;
     server_name cloud.example.com;
     server_name_in_redirect off;
     rewrite     ^ https://$server_name$request_uri? permanent;

 server {
     listen      443 ssl;
     server_name cloud.example.com;

     ssl_certificate     /etc/letsencrypt/live/cloud.example.com/fullchain.pem;
     ssl_certificate_key /etc/letsencrypt/live/cloud.example.com/privkey.pem;

     location /.well-known {
         alias /var/www/nextcloud/.well-known;

But after enabling this vhost I am unable to access Nextcloud through proxy because it redirects me to the snap installation (cloud.example.com:8443)

Can you help me with this issue?

Thank you,

Hi Petrcze,

try to add the following lines into your config file. be sure to edit your domain:

‘trusted_domains’ =>
array (
‘overwrite.cli.url’ => ‘https://YOUR_NC_DOMAIN_HERE’,
‘overwriteprotocol’ => ‘https’,
‘overwritehost’ => ‘YOUR_NC_DOMAIN_HERE’,

PS: You may need to add your NC domain Port with :PORT_NUMBER

I hope this helps

Thank you, I missed overwritehost value.

Have a great day!