Nextcloud:16.0.1-apache behind traefik

Nextcloud version (eg, 12.0.2): 16.0.1-apache (docker image from docker hub)
Operating system and version (eg, Ubuntu 17.04): Debian 9
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.25 (inside docker image)
PHP version (eg, 7.1): 7.3.5 (inside docker image)

The issue you are facing:
After pulling the image from docker hub and adding it into docker-compose.yml

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

Steps to replicate it:

  1. pull docker image nextcloud:16.0.1-apache
  2. add to docker file and put behind traefik as a reverse proxy
  3. try to access the host

The output of your Nextcloud log in Admin > Logging: INACCESSABLE

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

The output of your Apache/nginx/system log in /var/log/____: Unable to retrive from docker

Log from docker-compose logs nextcloud:

nextcloud    | [Tue May 21 19:03:02.886407 2019] [php7:warn] [pid 32] [client 172.18.0.1:41860] PHP Warning:  fileperms(): stat failed for /var/www/nextcloud/data/nextcloud.log in /var/www/html/lib/private/Log/File.php on line 140
nextcloud    | [Tue May 21 19:03:02.886485 2019] [php7:notice] [pid 32] [client 172.18.0.1:41860] {"reqId":"450LUdwE8VmrhsF70Xom","level":3,"time":"2019-05-21T19:03:02+00:00","remoteAddr":"172.18.0.1","user":"--","app":"PHP","method":"GET","url":"\\/","message":"fileperms(): stat failed for \\/var\\/www\\/nextcloud\\/data\\/nextcloud.log at \\/var\\/www\\/html\\/lib\\/private\\/Log\\/File.php#140","userAgent":"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko\\/20100101 Firefox\\/66.0","version":"7.0.2.1"}
nextcloud    | [Tue May 21 19:03:02.886531 2019] [php7:notice] [pid 32] [client 172.18.0.1:41860] {"reqId":"450LUdwE8VmrhsF70Xom","level":3,"time":"2019-05-21T19:03:02+00:00","remoteAddr":"172.18.0.1","user":"--","app":"index","method":"GET","url":"\\/","message":{"Exception":"Doctrine\\\\DBAL\\\\DBALException","Message":"Failed to connect to the database: An exception occurred in driver: SQLSTATE[08006] [7] timeout expired","Code":0,"Trace":[{"file":"\\/var\\/www\\/html\\/3rdparty\\/doctrine\\/dbal\\/lib\\/Doctrine\\/DBAL\\/Connection.php","line":448,"function":"connect","class":"OC\\\\DB\\\\Connection","type":"->","args":[]},{"file":"\\/var\\/www\\/html\\/3rdparty\\/doctrine\\/dbal\\/lib\\/Doctrine\\/DBAL\\/Connection.php","line":410,"function":"getDatabasePlatformVersion","class":"Doctrine\\\\DBAL\\\\Connection","type":"->","args":[]},{"file":"\\/var\\/www\\/html\\/3rdparty\\/doctrine\\/dbal\\/lib\\/Doctrine\\/DBAL\\/Connection.php","line":354,"function":"detectDatabasePlatform","class":"Doctrine\\\\DBAL\\\\Connection","type":"->","args":[]},{"file":"\\/var\\/www\\/html\\/3rdparty\\/doctrine\\/dbal\\/lib\\/Doctrine\\/DBAL\\/Connection.php","line":710,"function":"getDatabasePlatform","class":"Doctrine\\\\DBAL\\\\Connection","type":"->","args":[]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/DB\\/Connection.php","line":151,"function":"setTransactionIsolation","class":"Doctrine\\\\DBAL\\\\Connection","type":"->","args":[2]},{"file":"\\/var\\/www\\/html\\/3rdparty\\/doctrine\\/dbal\\/lib\\/Doctrine\\/DBAL\\/DriverManager.php","line":181,"function":"__construct","class":"OC\\\\DB\\\\Connection","type":"->","args":[{"adapter":"OC\\\\DB\\\\AdapterPgSql","driver":"pdo_pgsql","wrapperClass":"OC\\\\DB\\\\Connection","user":"nextclouder","password":"yg$gGIK!@GYgkj4vfvz4*&","host":"vpsfree.vojtamares.com","dbname":"nextcloud","tablePrefix":"","sqlite.journal_mode":"WAL","defaultTableOptions":{"collate":"utf8_bin","tablePrefix":""}},{"__class__":"Doctrine\\\\DBAL\\\\Driver\\\\PDOPgSql\\\\Driver"},{"__class__":"Doctrine\\\\DBAL\\\\Configuration"},{"__class__":"Doctrine\\\\Common\\\\EventManager"}]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/DB\\/ConnectionFactory.php","line":156,"function":"getConnection","class":"Doctrine\\\\DBAL\\\\DriverManager","type":"::","args":[{"adapter":"OC\\\\DB\\\\AdapterPgSql","driver":"pdo_pgsql","wrapperClass":"OC\\\\DB\\\\Connection","user":"nextclouder","password":"yg$gGIK!@GYgkj4vfvz4*&","host":"vpsfree.vojtamares.com","dbname":"nextcloud","tablePrefix":"","sqlite.journal_mode":"WAL","defaultTableOptions":{"collate":"utf8_bin","tablePrefix":""}},{"__class__":"Doctrine\\\\DBAL\\\\Configuration"},{"__class__":"Doctrine\\\\Common\\\\EventManager"}]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/Server.php","line":641,"function":"getConnection","class":"OC\\\\DB\\\\ConnectionFactory","type":"->","args":["pgsql",{"user":"nextclouder","password":"yg$gGIK!@GYgkj4vfvz4*&","host":"vpsfree.vojtamares.com","dbname":"nextcloud","tablePrefix":"","sqlite.journal_mode":"WAL","defaultTableOptions":{"collate":"utf8_bin","tablePrefix":""}}]},{"file":"\\/var\\/www\\/html\\/3rdparty\\/pimple\\/pimple\\/src\\/Pimple\\/Container.php","line":118,"function":"OC\\\\{closure}","class":"OC\\\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/ServerContainer.php","line":125,"function":"offsetGet","class":"Pimple\\\\Container","type":"->","args":["OCP\\\\IDBConnection"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/AppFramework\\/Utility\\/SimpleContainer.php","line":165,"function":"query","class":"OC\\\\ServerContainer","type":"->","args":["OCP\\\\IDBConnection"]},{"file":"\\/var\\/www\\/html\\/3rdparty\\/pimple\\/pimple\\/src\\/Pimple\\/Container.php","line":114,"function":"OC\\\\AppFramework\\\\Utility\\\\{closure}","class":"OC\\\\AppFramework\\\\Utility\\\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/ServerContainer.php","line":125,"function":"offsetGet","class":"Pimple\\\\Container","type":"->","args":["DatabaseConnection"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/Server.php","line":1560,"function":"query","class":"OC\\\\ServerContainer","type":"->","args":["DatabaseConnection"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/Server.php","line":456,"function":"getDatabaseConnection","class":"OC\\\\Server","type":"->","args":[]},{"file":"\\/var\\/www\\/html\\/3rdparty\\/pimple\\/pimple\\/src\\/Pimple\\/Container.php","line":118,"function":"OC\\\\{closure}","class":"OC\\\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/ServerContainer.php","line":125,"function":"offsetGet","class":"Pimple\\\\Container","type":"->","args":["OC\\\\AppConfig"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/Server.php","line":695,"function":"query","class":"OC\\\\ServerContainer","type":"->","args":["OC\\\\AppConfig"]},{"file":"\\/var\\/www\\/html\\/3rdparty\\/pimple\\/pimple\\/src\\/Pimple\\/Container.php","line":118,"function":"OC\\\\{closure}","class":"OC\\\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/ServerContainer.php","line":125,"function":"offsetGet","class":"Pimple\\\\Container","type":"->","args":["OC\\\\App\\\\AppManager"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/AppFramework\\/Utility\\/SimpleContainer.php","line":165,"function":"query","class":"OC\\\\ServerContainer","type":"->","args":["OC\\\\App\\\\AppManager"]},{"file":"\\/var\\/www\\/html\\/3rdparty\\/pimple\\/pimple\\/src\\/Pimple\\/Container.php","line":114,"function":"OC\\\\AppFramework\\\\Utility\\\\{closure}","class":"OC\\\\AppFramework\\\\Utility\\\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/ServerContainer.php","line":125,"function":"offsetGet","class":"Pimple\\\\Container","type":"->","args":["AppManager"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/Server.php","line":1731,"function":"query","class":"OC\\\\ServerContainer","type":"->","args":["AppManager"]},{"file":"\\/var\\/www\\/html\\/lib\\/private\\/legacy\\/template.php","line":284,"function":"getAppManager","class":"OC\\\\Server","type":"->","args":[]},{"file":"\\/var\\/www\\/html\\/lib\\/base.php","line":264,"function":"printErrorPage","class":"OC_Template","type":"::","args":["Neda\\u0159\\u00ed se zapisovat do adres\\u00e1\\u0159e \\u201econfig\\u201c!","Toto obvykle lze vy\\u0159e\\u0161it ud\\u011blen\\u00edm opr\\u00e1vn\\u011bn\\u00ed k z\\u00e1pisu do ko\\u0159enov\\u00e9 slo\\u017eky webu pro \\u00fa\\u010det, pod kter\\u00fdm je provozov\\u00e1n webov\\u00fd server. Viz https:\\/\\/docs.nextcloud.com\\/server\\/16\\/go.php?to=admin-dir_permissions. Nebo, pokud chcete m\\u00edt soubor config.php pouze pro \\u010dten\\u00ed, nastavte v n\\u011bm volbu \\u201econfig_is_read_only\\u201c na hodnotu true. Viz https:\\/\\/docs.nextcloud.com\\/server\\/16\\/go.php?to=admin-config",503]},{"file":"\\/var\\/www\\/html\\/lib\\/base.php","line":645,"function":"checkConfig","class":"OC","type":"::","args":[]},{"file":"\\/var\\/www\\/html\\/lib\\/base.php","line":1056,"function":"init","class":"OC","type":"::","args":[]},{"file":"\\/var\\/www\\/html\\/index.php","line":40,"args":["\\/var\\/www\\/html\\/lib\\/base.php"],"function":"require_once"}],"File":"\\/var\\/www\\/html\\/lib\\/private\\/DB\\/Connection.php","Line":64,"CustomMessage":"--"},"userAgent":"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko\\/20100101 Firefox\\/66.0","version":"7.0.2.1"}
nextcloud    | [Tue May 21 19:03:02.896569 2019] [php7:warn] [pid 32] [client 172.18.0.1:41860] PHP Warning:  fileperms(): stat failed for /var/www/nextcloud/data/nextcloud.log in /var/www/html/lib/private/Log/File.php on line 140
nextcloud    | [Tue May 21 19:03:02.896609 2019] [php7:notice] [pid 32] [client 172.18.0.1:41860] {"reqId":"450LUdwE8VmrhsF70Xom","level":3,"time":"2019-05-21T19:03:02+00:00","remoteAddr":"172.18.0.1","user":"--","app":"PHP","method":"GET","url":"\\/","message":"fileperms(): stat failed for \\/var\\/www\\/nextcloud\\/data\\/nextcloud.log at \\/var\\/www\\/html\\/lib\\/private\\/Log\\/File.php#140","userAgent":"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko\\/20100101 Firefox\\/66.0","version":"7.0.2.1"}
nextcloud    | [Tue May 21 19:03:02.896633 2019] [php7:notice] [pid 32] [client 172.18.0.1:41860] {"reqId":"450LUdwE8VmrhsF70Xom","level":3,"time":"2019-05-21T19:03:02+00:00","remoteAddr":"172.18.0.1","user":"--","app":"PHP","method":"GET","url":"\\/","message":"chmod(): No such file or directory at \\/var\\/www\\/html\\/lib\\/private\\/Log\\/File.php#141","userAgent":"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko\\/20100101 Firefox\\/66.0","version":"7.0.2.1"}
nextcloud    | 172.18.0.1 - - [21/May/2019:19:02:02 +0000] "GET / HTTP/1.1" 500 5012 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/js/oc-dialogs.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 10280 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/js/oc-requesttoken.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 519 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/css/guest.css?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 5808 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/js/js.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 11520 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/js/mimetype.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 1701 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/js/select2-toggleselect.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 968 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/js/mimetypelist.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 1534 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/search/js/search.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 1986 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/l10n/cs.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 17730 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/js/files/fileinfo.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 1232 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/search/js/searchprovider.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 4049 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/js/files/client.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 5997 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/js/dist/main.js?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 370552 "http://localhost:8010/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/img/logo/logo.svg?v=1 HTTP/1.1" 200 609 "http://localhost:8010/core/css/guest.css?v=ba222ded25d957b900c03bef914333cd" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 172.18.0.1 - - [21/May/2019:19:03:03 +0000] "GET /core/img/background.png?v=2 HTTP/1.1" 200 103025 "http://localhost:8010/core/css/guest.css?v=ba222ded25d957b900c03bef914333cd" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
nextcloud    | 127.0.0.1 - - [21/May/2019:19:03:09 +0000] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.25 (Debian) PHP/7.3.5 (internal dummy connection)"

I used SSH tunnel to connect to server and to the nextcloud since website is behind cloudflare which displays its 502 error page instead of Nextclouds 500.

Traefik is configured properly as far as I know, since other services run on same configurations without issues.