Unable to setup NGINX proxy for snap nextcloud - redirecting

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

Scheme:
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,
Petr.

Hi Petrcze,

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

ā€˜trusted_domainsā€™ =>
array (
0 => ā€˜YOUR_NC_DOMAIN_HEREā€™,
),
ā€˜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!