Incorrect redirections in docker container behind reverse proxy

Greetings

I am trying to run the official Nextcloud docker container behind a reverse proxy. In my docker-compose.yml file, I have this:

  cloud:
    image: "nextcloud"
    volumes:
      - ./cloud:/var/www/html
    depends_on:
      - db
    networks:
      - db_net
      - web_internal

  webserver:
    image: "nginx"
    volumes:
      - ./webserver/conf.d:/etc/nginx/conf.d:ro
      - ./webserver/nginx.conf:/etc/nginx/nginx.conf
      - ./webserver/www:/var/www
      - /etc/letsencrypt:/etc/letsencrypt
    ports:
      - 0.0.0.0:80:80/tcp
      - 0.0.0.0:443:443/tcp
    depends_on:
      - cloud
    networks:
      - web_internal

The relevant nginx config file contains this:

server {
  listen 443;
  server_name cloud.domain.tld;

  location / {
    proxy_pass http://cloud:80;
  }
}

When I access https://cloud.domain.tld, I see the configuration page, where I can create a new user and set up the database connection. When I submit the form, the configuration completes and I am taken to my dashboard.

However, when I access https://cloud.domain.tld from a different browser, I’m 302’d to http://cloud/login, which obviously doesn’t work:

pmg@PMG-MSI:~$ curl https://cloud.pmg-ware.net -I
HTTP/1.1 302 Found
Server: nginx/1.15.8
...
Location: https://cloud/login

So, I went to the /var/www/html/config/conf.php file, and made sure the following lines are there:

  'overwritehost'     => 'cloud.domain.tld',
  'overwriteprotocol' => 'https',
  'overwritewebroot'  => '/',

Then I ran docker restart, but the problem persists.

Any suggestions on how I should fix this?
Thanks.

I tried doing everything from scratch, and it works now. I’m not sure what I did differently this time, I probably mounted a wrong data directory or something.