Having redirect problems where domain is not included

Nextcloud version (eg, 12.0.2): 16.0.1
Operating system and version (eg, Ubuntu 17.04): nextcloud:apache docker image
Apache or nginx version (eg, Apache 2.4.25):
PHP version (eg, 7.1):

So I had this working for a long time. I swear I didn’t change anything, but now when I go to https://[my-nextcloud-server].com/ it tries to redirect to login by going to: http://login/
It’s like whatever is performing the redirect doesn’t know what the domain name is. Not sure how to debug this.

Basically any redirect that nextcloud tries to do strips off the domain and ends up as http://[path-after-domain-here]/

However if I go directly to a page, like type in “https://[my-nextcloud-server]/apps/files/” in my browser. Then it works.

In a nutshell I have nginx proxy_passing to a nextcloud:apache container on a subdomain

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

$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
  'overwritehost' => 'my-hostname-here',
  'instanceid' => 'some_id',
  'passwordsalt' => 'some_salt',
  'secret' => 'some_secret',
  'trusted_domains' =>
  array (
    0 => 'my-hostname-here',
  'datadirectory' => '/opt/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => 'http://my-hostname-here',
  'dbname' => 'nextcloud',
  'dbhost' => 'nextcloud-db',
  'dbport' => '',
  'dbtableprefix' => '',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'a_password',
  'installed' => true,
  'updater.secret' => 'some_secret',

Here’s my nginx config for good measure:

upstream docker-nextcloud {
  server nextcloud:80;

server {
  listen 80;
  listen [::]:80;

  return 301 https://$server_name$request_uri;

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  server_name some.server.com;

  root /var/www/html;

  include /etc/nginx/mime.types;
  sendfile on;

  ssl_certificate /etc/letsencrypt/live/some.server.com/fullchain.pem; # managed by Certbot
  ssl_certificate_key /etc/letsencrypt/live/some.server.com/privkey.pem; # managed by Certbot

  include /etc/letsencrypt/options-ssl-nginx.conf;

  location ~ /.well-known/acme-challenge {
    allow all;
    root /data/letsencrypt;

  add_header X-Content-Type-Options nosniff;
  add_header X-Robots-Tag none;
  add_header X-Download-Options noopen;
  add_header X-Permitted-Cross-Domain-Policies none;
  add_header X-XSS-Protection "1; mode=block";
  add_header Strict-Transport-Security 15552000;
  add_header Referrer-Policy no-referrer;

  client_max_body_size 10G;
  gzip on;
  gzip_vary on;
  gzip_comp_level 4;
  gzip_min_length 256;
  gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
  access_log /var/log/nginx/scripts.log scripts;
  location / {
    proxy_pass http://docker-nextcloud/;
    proxy_set_header Host some.server.com;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
    access_log /var/log/nginx/nextcloud.access.log;
    error_log /var/log/nginx/nextcloud.error.log;

Thanks for any help!

Any log files from the nginx server – I’m guessing thats where the location re-write is coming from unless you’ve messed something up with your DNS overrides at the router level of /etc/hosts file