Permanent redirect sharing folders in an iFrame on a trusted domain

Nextcloud version - 16.0.3.0 (cannot update to the latest version as update repeatedly fails)
Operating system - Linux
Apache - Apache/2.4.39
PHP version - 7.2.17

I need to use iFrames for shared folders (public links) on our company domain and have followed all advice on the forums for similar problems but without success. The iFrame permanently redirects (302) to the public link resulting in a ‘too many redirects error’ in all browsers.

Nextcloud is installed in one of our domains and the iFrame needs to be in another of our domains (i.e. they are different domains owned by the same company). I have added the iFrame domain as a trusted domain in config.php; set the content security policy to allow the iFrame domain and frame ancestors and I have even tried removing XFrame headers ‘SAME ORIGIN’ from .htaccess but the iFrame fails to load due to too many redirects.


Is this the first time you’ve seen this error? Y

Steps to replicate it:

  1. Get shared public link
  2. Use shared public link in iFrame on a trusted domain

The output of your Nextcloud log in Admin > Logging:

{"reqId":"XffULETJiMmX@6iBCqrt7AAAABg","level":3,"time":"2019-12-16T18:59:59+00:00","remoteAddr":"217.45.174.64","user":"loknextcloud","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/core\/preview?fileId=20&x=32&y=32","message":"imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: Insufficient memory (case 4) at \/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/legacy\/image.php#560","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"XffVAgOkTOIrOuiCa2PvUAAAAAY","level":3,"time":"2019-12-16T19:03:31+00:00","remoteAddr":"217.45.174.64","user":"loknextcloud","app":"federation","method":"POST","url":"\/nextcloud\/index.php\/apps\/federation\/trusted-servers","message":{"Exception":"OC\\HintException","Message":"No server to federate with found","Code":0,"Trace":[{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/apps\/federation\/lib\/Controller\/SettingsController.php","line":68,"function":"checkServer","class":"OCA\\Federation\\Controller\\SettingsController","type":"->","args":["https:\/\/www.icompute-uk.com"]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":166,"function":"addServer","class":"OCA\\Federation\\Controller\\SettingsController","type":"->","args":["https:\/\/www.icompute-uk.com"]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":99,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Federation\\Controller\\SettingsController"},"addServer"]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/AppFramework\/App.php","line":126,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Federation\\Controller\\SettingsController"},"addServer"]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Federation\\Controller\\SettingsController","addServer",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"federation.Settings.addServer"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"_route":"federation.Settings.addServer"}]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/Route\/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"_route":"federation.Settings.addServer"}]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/base.php","line":975,"function":"match","class":"OC\\Route\\Router","type":"->","args":["\/apps\/federation\/trusted-servers"]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/apps\/federation\/lib\/Controller\/SettingsController.php","Line":118,"Hint":"No server to federate with found","CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"XffVzAOkTOIrOuiCa2PvywAAAAY","level":3,"time":"2019-12-16T19:06:56+00:00","remoteAddr":"217.45.174.64","user":"loknextcloud","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/settings\/apps","message":"Out of memory (allocated 41943040) (tried to allocate 20480 bytes) at \/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/3rdparty\/leafo\/scssphp\/src\/Compiler.php#2957","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"XffYy-iv7ghKU9YdzYd-ewAAAB8","level":3,"time":"2019-12-16T19:19:43+00:00","remoteAddr":"217.45.174.64","user":"loknextcloud","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/core\/preview?fileId=20&x=32&y=32","message":"imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: Insufficient memory (case 4) at \/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/legacy\/image.php#560","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"XfffnEBKtNIB@r5rhqkP-gAAAAs","level":3,"time":"2019-12-16T19:48:47+00:00","remoteAddr":"217.45.174.64","user":"loknextcloud","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/core\/preview?fileId=20&x=32&y=32","message":"imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: Insufficient memory (case 4) at \/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/legacy\/image.php#560","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"XfikB4WdRhfdj7uiN8WSNAAAACY","level":3,"time":"2019-12-17T09:46:48+00:00","remoteAddr":"217.45.174.64","user":"--","app":"index","method":"GET","url":"\/nextcloud\/index.php\/s\/CftzNYHPRmmoKir","message":{"Exception":"TypeError","Message":"Argument 2 passed to OCP\\AppFramework\\Http\\Template\\PublicTemplateResponse::OCP\\AppFramework\\Http\\Template\\{closure}() must implement interface OCP\\AppFramework\\Http\\Template\\IMenuAction, null given","Code":0,"Trace":[{"function":"OCP\\AppFramework\\Http\\Template\\{closure}","class":"OCP\\AppFramework\\Http\\Template\\PublicTemplateResponse","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/public\/AppFramework\/Http\/Template\/PublicTemplateResponse.php","line":101,"function":"usort","args":[["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"],{"__class__":"Closure"}]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/apps\/files_sharing\/lib\/Controller\/ShareController.php","line":483,"function":"setHeaderActions","class":"OCP\\AppFramework\\Http\\Template\\PublicTemplateResponse","type":"->","args":[["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"]]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":166,"function":"showShare","class":"OCA\\Files_Sharing\\Controller\\ShareController","type":"->","args":[""]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":99,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files_Sharing\\Controller\\ShareController"},"showShare"]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/AppFramework\/App.php","line":126,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files_Sharing\\Controller\\ShareController"},"showShare"]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Files_Sharing\\Controller\\ShareController","showShare",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"token":"CftzNYHPRmmoKir","_route":"files_sharing.sharecontroller.showShare"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"token":"CftzNYHPRmmoKir","_route":"files_sharing.sharecontroller.showShare"}]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/private\/Route\/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"token":"CftzNYHPRmmoKir","_route":"files_sharing.sharecontroller.showShare"}]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/base.php","line":975,"function":"match","class":"OC\\Route\\Router","type":"->","args":["\/s\/CftzNYHPRmmoKir"]},{"file":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/home\/cluster-sites\/3\/i\/icomp.site\/public_html\/nextcloud\/lib\/public\/AppFramework\/Http\/Template\/PublicTemplateResponse.php","Line":99,"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}

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

<?php
$CONFIG = array (
  'instanceid' => '',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' => 
  array (
    0 => 'icomp.site',
    1 => 'icompute-uk.com',  
  ),
  'datadirectory' => '/home/cluster-sites/3/i/icomp.site/public_html/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '16.0.3.0',
  'overwrite.cli.url' => 'https://icomp.site/nextcloud',
  'dbname' => '',
  'dbhost' => '',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '',
  'dbpassword' => '',
  'installed' => true,
  'mail_from_address' => 'office',
  'mail_smtpmode' => 'sendmail',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'icompute-uk.com',
  'mail_smtpauthtype' => 'LOGIN',
  'simpleSignUpLink.shown' => false,  	
);