Nextcloud V22 Login redirects to login page on reverse proxy

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 22.1.0.1
Operating system and version (eg, Ubuntu 20.04): Unraid
Apache or nginx version (eg, Apache 2.4.25): NGINX
PHP version (eg, 7.4): 7.4.23

The issue you are facing:

If I connect to my nextcloud server on LAN, with local IP, it loads perfectly.

If I connect through reverse proxy, the login page loads, then when I submit the correct credentials, it reloads and add’s: login?redirect_url=/apps/dashboard/

Thus landing me back to the same login page, with the new URL.

This issue seems new as I dont recall having it before when I was setting up things, and using the hosted site through reverse proxy before to make sure it worked.

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

Steps to replicate it:

Just use reverse proxy.

The output of your Nextcloud log in Admin > Logging:

{"reqId":"ugwHNP19QJM3LlUdPTlt","level":2,"time":"2021-09-29T19:25:19+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifying photos of user sinaplej","userAgent":"--","version":"22.1.0.1"}
{"reqId":"ugwHNP19QJM3LlUdPTlt","level":2,"time":"2021-09-29T19:25:19+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process output: sh: exec: line 1: : Permission denied\n","userAgent":"--","version":"22.1.0.1"}
{"reqId":"ugwHNP19QJM3LlUdPTlt","level":2,"time":"2021-09-29T19:25:19+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process errored","userAgent":"--","version":"22.1.0.1"}
{"reqId":"ugwHNP19QJM3LlUdPTlt","level":2,"time":"2021-09-29T19:25:19+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process error","userAgent":"--","version":"22.1.0.1"}
{"reqId":"d7DT5cPb8ubaLFg30sRW","level":2,"time":"2021-09-29T20:00:25+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifying photos of user sinaplej","userAgent":"--","version":"22.1.0.1"}
{"reqId":"d7DT5cPb8ubaLFg30sRW","level":2,"time":"2021-09-29T20:00:25+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process output: sh: exec: line 1: : Permission denied\n","userAgent":"--","version":"22.1.0.1"}
{"reqId":"d7DT5cPb8ubaLFg30sRW","level":2,"time":"2021-09-29T20:00:25+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process errored","userAgent":"--","version":"22.1.0.1"}
{"reqId":"d7DT5cPb8ubaLFg30sRW","level":2,"time":"2021-09-29T20:00:25+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process error","userAgent":"--","version":"22.1.0.1"}
{"reqId":"HEkaVjC7wd2I3AiFK6zN","level":2,"time":"2021-09-29T20:35:13+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifying photos of user sinaplej","userAgent":"--","version":"22.1.0.1"}
{"reqId":"HEkaVjC7wd2I3AiFK6zN","level":2,"time":"2021-09-29T20:35:13+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process output: sh: exec: line 1: : Permission denied\n","userAgent":"--","version":"22.1.0.1"}
{"reqId":"HEkaVjC7wd2I3AiFK6zN","level":2,"time":"2021-09-29T20:35:13+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process errored","userAgent":"--","version":"22.1.0.1"}
{"reqId":"HEkaVjC7wd2I3AiFK6zN","level":2,"time":"2021-09-29T20:35:13+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process error","userAgent":"--","version":"22.1.0.1"}
{"reqId":"owo1OW9j6nQQsaA8nY1Y","level":2,"time":"2021-09-29T21:05:14+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifying photos of user sinaplej","userAgent":"--","version":"22.1.0.1"}
{"reqId":"owo1OW9j6nQQsaA8nY1Y","level":2,"time":"2021-09-29T21:05:14+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process output: sh: exec: line 1: : Permission denied\n","userAgent":"--","version":"22.1.0.1"}
{"reqId":"owo1OW9j6nQQsaA8nY1Y","level":2,"time":"2021-09-29T21:05:14+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process errored","userAgent":"--","version":"22.1.0.1"}
{"reqId":"owo1OW9j6nQQsaA8nY1Y","level":2,"time":"2021-09-29T21:05:14+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process error","userAgent":"--","version":"22.1.0.1"}
{"reqId":"jw07xzUCfth0sizue8fA","level":2,"time":"2021-09-29T21:40:05+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifying photos of user sinaplej","userAgent":"--","version":"22.1.0.1"}
{"reqId":"jw07xzUCfth0sizue8fA","level":2,"time":"2021-09-29T21:40:05+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process output: sh: exec: line 1: : Permission denied\n","userAgent":"--","version":"22.1.0.1"}
{"reqId":"jw07xzUCfth0sizue8fA","level":2,"time":"2021-09-29T21:40:05+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process errored","userAgent":"--","version":"22.1.0.1"}
{"reqId":"jw07xzUCfth0sizue8fA","level":2,"time":"2021-09-29T21:40:05+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process error","userAgent":"--","version":"22.1.0.1"}
{"reqId":"LLVBrVDdUYMgpeTUka0h","level":2,"time":"2021-09-29T21:43:01+00:00","remoteAddr":"","user":"--","app":"fulltextsearch","method":"","url":"--","message":"Exception while cronIndex: Doctrine\\DBAL\\Exception\\ConnectionLost - An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away","userAgent":"--","version":"22.1.0.1"}
{"reqId":"LLVBrVDdUYMgpeTUka0h","level":3,"time":"2021-09-29T21:43:01+00:00","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":"Error while running background job (class: OCA\\FullTextSearch\\Cron\\Index, arguments: )","userAgent":"--","version":"22.1.0.1","exception":{"Exception":"Doctrine\\DBAL\\Exception","Message":"Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2006] MySQL server has gone away","Code":2006,"Trace":[{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1486,"function":"connect","class":"OC\\DB\\Connection","type":"->"},{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1014,"function":"getWrappedConnection","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/Connection.php","line":231,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":210,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/config/www/nextcloud/apps/fulltextsearch/lib/Db/TickRequest.php","line":134,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/config/www/nextcloud/apps/fulltextsearch/lib/Service/RunningService.php","line":127,"function":"getTickById","class":"OCA\\FullTextSearch\\Db\\TickRequest","type":"->"},{"file":"/config/www/nextcloud/apps/fulltextsearch/lib/Model/Runner.php","line":413,"function":"stop","class":"OCA\\FullTextSearch\\Service\\RunningService","type":"->"},{"file":"/config/www/nextcloud/apps/fulltextsearch/lib/Cron/Index.php","line":107,"function":"exception","class":"OCA\\FullTextSearch\\Model\\Runner","type":"->"},{"file":"/config/www/nextcloud/lib/private/BackgroundJob/Job.php","line":51,"function":"run","class":"OCA\\FullTextSearch\\Cron\\Index","type":"->"},{"file":"/config/www/nextcloud/lib/private/BackgroundJob/TimedJob.php","line":58,"function":"execute","class":"OC\\BackgroundJob\\Job","type":"->"},{"file":"/config/www/nextcloud/cron.php","line":127,"function":"execute","class":"OC\\BackgroundJob\\TimedJob","type":"->"}],"File":"/config/www/nextcloud/lib/private/DB/Connection.php","Line":87,"CustomMessage":"Error while running background job (class: OCA\\FullTextSearch\\Cron\\Index, arguments: )"}}
{"reqId":"LLVBrVDdUYMgpeTUka0h","level":3,"time":"2021-09-29T21:43:01+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2006] MySQL server has gone away","userAgent":"--","version":"22.1.0.1","exception":{"Exception":"Doctrine\\DBAL\\Exception","Message":"Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2006] MySQL server has gone away","Code":2006,"Trace":[{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1486,"function":"connect","class":"OC\\DB\\Connection","type":"->"},{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":770,"function":"getWrappedConnection","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/3rdparty/doctrine/dbal/src/Query/Expression/ExpressionBuilder.php","line":307,"function":"quote","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/config/www/nextcloud/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php","line":422,"function":"literal","class":"Doctrine\\DBAL\\Query\\Expression\\ExpressionBuilder","type":"->"},{"file":"/config/www/nextcloud/lib/private/BackgroundJob/JobList.php","line":304,"function":"literal","class":"OC\\DB\\QueryBuilder\\ExpressionBuilder\\ExpressionBuilder","type":"->"},{"file":"/config/www/nextcloud/lib/private/BackgroundJob/JobList.php","line":292,"function":"unlockJob","class":"OC\\BackgroundJob\\JobList","type":"->"},{"file":"/config/www/nextcloud/cron.php","line":131,"function":"setLastJob","class":"OC\\BackgroundJob\\JobList","type":"->"}],"File":"/config/www/nextcloud/lib/private/DB/Connection.php","Line":87,"CustomMessage":"--"}}
{"reqId":"2OBbIkay5qcPq61776fi","level":2,"time":"2021-09-29T22:20:25+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifying photos of user sinaplej","userAgent":"--","version":"22.1.0.1"}
{"reqId":"2OBbIkay5qcPq61776fi","level":2,"time":"2021-09-29T22:20:26+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process output: sh: exec: line 1: : Permission denied\n","userAgent":"--","version":"22.1.0.1"}
{"reqId":"2OBbIkay5qcPq61776fi","level":2,"time":"2021-09-29T22:20:26+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process errored","userAgent":"--","version":"22.1.0.1"}
{"reqId":"2OBbIkay5qcPq61776fi","level":2,"time":"2021-09-29T22:20:26+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process error","userAgent":"--","version":"22.1.0.1"}
{"reqId":"ArfAP8CaaPxdU5MoTv48","level":2,"time":"2021-09-29T22:55:06+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifying photos of user sinaplej","userAgent":"--","version":"22.1.0.1"}
{"reqId":"ArfAP8CaaPxdU5MoTv48","level":2,"time":"2021-09-29T22:55:06+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process output: sh: exec: line 1: : Permission denied\n","userAgent":"--","version":"22.1.0.1"}
{"reqId":"ArfAP8CaaPxdU5MoTv48","level":2,"time":"2021-09-29T22:55:06+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process errored","userAgent":"--","version":"22.1.0.1"}
{"reqId":"ArfAP8CaaPxdU5MoTv48","level":2,"time":"2021-09-29T22:55:06+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process error","userAgent":"--","version":"22.1.0.1"}
{"reqId":"DI73rwUiKuZIqI6487XH","level":2,"time":"2021-09-29T23:25:12+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifying photos of user sinaplej","userAgent":"--","version":"22.1.0.1"}
{"reqId":"DI73rwUiKuZIqI6487XH","level":2,"time":"2021-09-29T23:25:13+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process output: sh: exec: line 1: : Permission denied\n","userAgent":"--","version":"22.1.0.1"}
{"reqId":"DI73rwUiKuZIqI6487XH","level":2,"time":"2021-09-29T23:25:13+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process errored","userAgent":"--","version":"22.1.0.1"}
{"reqId":"DI73rwUiKuZIqI6487XH","level":2,"time":"2021-09-29T23:25:13+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process error","userAgent":"--","version":"22.1.0.1"}
{"reqId":"YSW6raIlIIqu41pHbh2z","level":2,"time":"2021-09-29T23:55:17+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifying photos of user sinaplej","userAgent":"--","version":"22.1.0.1"}
{"reqId":"YSW6raIlIIqu41pHbh2z","level":2,"time":"2021-09-29T23:55:18+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process output: sh: exec: line 1: : Permission denied\n","userAgent":"--","version":"22.1.0.1"}
{"reqId":"YSW6raIlIIqu41pHbh2z","level":2,"time":"2021-09-29T23:55:18+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process errored","userAgent":"--","version":"22.1.0.1"}
{"reqId":"YSW6raIlIIqu41pHbh2z","level":2,"time":"2021-09-29T23:55:18+00:00","remoteAddr":"","user":"--","app":"recognize","method":"","url":"--","message":"Classifier process error","userAgent":"--","version":"22.1.0.1"}

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

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'datadirectory' => '/data',
  'instanceid' => 'oc9sc9xsptcg',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => '192.168.1.55',
    1 => 'localhost',
    2 => 'nextcloud.xxx.com',
	3 => 'https://nextcloud.xxx.com',
  ),
  'trusted_proxies' => 
  array (
    0 => '192.168.1.55',
    1 => 'nextcloud.xxx.com',
    2 => '192.168.1.55:1080',
	3 => 'https://nextcloud.xxx.com',
  ),
  'dbtype' => 'mysql',
  'version' => '22.1.0.1',
  'overwrite.cli.url' => 'https://192.168.1.55:4443',
  'dbname' => 'nextcloud',
  'dbhost' => '192.168.1.55:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'xxx',
  'installed' => true,
  'enable_previews' => true,
  'enabledPreviewProviders' => 
  array (
    1 => 'OC\\Preview\\PDF',
    2 => 'OC\\Preview\\Image',
    3 => 'OC\\Preview\\Photoshop',
    4 => 'OC\\Preview\\TIFF',
    5 => 'OC\\Preview\\SVG',
    6 => 'OC\\Preview\\Movie',
    7 => 'OC\\Preview\\MKV',
    8 => 'OC\\Preview\\MP4',
    9 => 'OC\\Preview\\AVI',
  ),
  'maintenance' => false,
  'allow_local_remote_servers' => true,
);

The output of my NGINX proxy

server {
  set $forward_scheme https;
  set $server         "192.168.1.55";
  set $port           4443;

  listen 8080;
listen [::]:8080;

listen 4443 ssl http2;
listen [::]:4443 ssl http2;


  server_name nextcloud.xxx.com;


  # Let's Encrypt SSL
  include conf.d/include/letsencrypt-acme-challenge.conf;
  include conf.d/include/ssl-ciphers.conf;
  ssl_certificate /etc/letsencrypt/live/npm-11/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/npm-11/privkey.pem;




# Asset Caching
  include conf.d/include/assets.conf;


  # Block Exploits
  include conf.d/include/block-exploits.conf;



  # HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)
  add_header Strict-Transport-Security "max-age=63072000;includeSubDomains; preload" always;





    # Force SSL
    include conf.d/include/force-ssl.conf;




proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;


  access_log /config/log/proxy-host-7_access.log proxy;
  error_log /config/log/proxy-host-7_error.log warn;







  location / {

    



  # HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)
  add_header Strict-Transport-Security "max-age=63072000;includeSubDomains; preload" always;





    
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;
    

    # Proxy!
    include conf.d/include/proxy.conf;
  }


  # Custom
  include /data/nginx/custom/server_proxy[.]conf;
}


Have a similar issue using the Snap version on a reverse proxy. I have my Talk page as a pinned tab in Firefox, and sometimes I get logged out for some reason, and then if I try to log in there, I often get just redirected to the login page again and again, until I open a new tab, go to the Nextcloud main page, and log in there.
On a totally random basis however, sometimes I can log in through the Talk page.