Nextcloud keeps logging me out of clients

Version Information

Nextcloud version: 18.0.1
Operating system and version: Debian 10

nginx version: 1.16.1
PHP version: 7.3.14

The issue you are facing:

My Nextcloud clients keeping logging out and getting hit with a 401 error. This happens on the Desktop client, the Android client, and the web client.

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

No. It keeps happening.

Steps to replicate it:

Log into any Nextcloud client

The output of your Nextcloud log in Admin > Logging:

{"reqId":"S65txebE8p5yg4y4jm00","level":2,"time":"2020-02-26T20:22:36+00:00","remoteAddr":"172.18.0.7","user":"myusername","app":"core","method":"POST","url":"/index.php/apps/maps/api/1.0/devices?altitude=113.0&lng=-122.30027215&accuracy=41.80800247192383&battery=65.0&lat=47.60816457&user_agent=MotoG%285%29Plus+%28PhoneTrack%2FAndroid%29&timestamp=1582748555","message":"Login failed: 'user' (Remote IP: '172.18.0.7')","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.10.1","version":"18.0.1.3","id":"5e57222bef6ff"}

The output of your config.php:

{
    "memcache.local": "\\OC\\Memcache\\APCu",
    "datadirectory": "***REMOVED SENSITIVE VALUE***",
    "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
    "overwrite.cli.url": "https:\/\/mydomain.com\/",
    "overwritehost": "mydomain.com",
    "overwriteprotocol": "https",
    "trusted_domains": [
        "mydomain.com"
    ],
    "instanceid": "***REMOVED SENSITIVE VALUE***",
    "passwordsalt": "***REMOVED SENSITIVE VALUE***",
    "secret": "***REMOVED SENSITIVE VALUE***",
    "dbtype": "mysql",
    "version": "18.0.1.3",
    "dbname": "***REMOVED SENSITIVE VALUE***",
    "dbhost": "***REMOVED SENSITIVE VALUE***",
    "dbport": "",
    "dbtableprefix": "oc_",
    "dbuser": "***REMOVED SENSITIVE VALUE***",
    "dbpassword": "***REMOVED SENSITIVE VALUE***",
    "mysql.utf8mb4": true,
    "installed": true,
    "mail_from_address": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpmode": "smtp",
    "mail_sendmailmode": "pipe",
    "mail_domain": "***REMOVED SENSITIVE VALUE***",
    "twofactor_enforced": "false",
    "twofactor_enforced_groups": [
        "admin"
    ],
    "twofactor_enforced_excluded_groups": [],
    "maintenance": false,
    "theme": "",
    "loglevel": 2,
    "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpport": "1587"
}

The output of your nginx log:

2020/02/23 04:59:09 [error] 411#411: *1572 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 5.101.0.209, server: _, request: "GET /index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=HelloThinkPHP HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37:80/index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=HelloThinkPHP"
2020/02/23 10:27:41 [error] 411#411: *2770 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 5.101.0.209, server: _, request: "GET /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37:80/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php"
2020/02/23 20:43:01 [error] 381#381: *658 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 5.101.0.209, server: _, request: "GET /index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=HelloThinkPHP HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37:443"
2020/02/23 23:16:17 [error] 381#381: *3547 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 93.177.163.137, server: _, request: "GET /sqlite/main.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37/"
2020/02/23 23:16:18 [error] 381#381: *3549 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 93.177.163.137, server: _, request: "GET /sqlitemanager/main.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37/"
2020/02/23 23:16:19 [error] 381#381: *3551 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 93.177.163.137, server: _, request: "GET /SQLiteManager/main.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37/"
2020/02/23 23:16:20 [error] 381#381: *3554 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 93.177.163.137, server: _, request: "GET /SQLite/main.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37/"
2020/02/23 23:16:20 [error] 381#381: *3556 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 93.177.163.137, server: _, request: "GET /SQlite/main.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37/"
2020/02/23 23:16:21 [error] 381#381: *3558 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 93.177.163.137, server: _, request: "GET /main.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37/"
2020/02/23 23:16:22 [error] 381#381: *3560 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 93.177.163.137, server: _, request: "GET /test/sqlite/SQLiteManager-1.2.0/SQLiteManager-1.2.0/main.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37/"
2020/02/23 23:16:23 [error] 381#381: *3562 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 93.177.163.137, server: _, request: "GET /SQLiteManager-1.2.4/main.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37/"
2020/02/23 23:16:23 [error] 381#381: *3564 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 93.177.163.137, server: _, request: "GET /agSearch/SQlite/main.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37/"
2020/02/24 04:23:43 [error] 385#385: *2289 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 5.101.0.209, server: _, request: "POST /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37:443"
2020/02/24 17:08:18 [error] 385#385: *14006 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 193.57.40.38, server: _, request: "GET /index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=HelloThinkPHP HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37:443"
2020/02/24 18:31:52 [error] 385#385: *16409 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 193.57.40.38, server: _, request: "POST /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37:443"
2020/02/26 06:24:03 [error] 385#385: *39483 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 5.101.0.209, server: _, request: "GET /index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=HelloThinkPHP HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37:443"
2020/02/26 16:56:12 [error] 385#385: *42322 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 5.101.0.209, server: _, request: "POST /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37:443"
2020/02/26 18:56:09 [error] 385#385: *42639 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 5.101.0.209, server: _, request: "GET /index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=HelloThinkPHP HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "97.232.68.37", referrer: "http://97.232.68.37:80/index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=HelloThinkPHP"
~