App shows 502 status

I deployed Nextcloud using the official Docker image. I used the following (relatively straightforward) script to do it:

if ! flyctl redis list | grep "msr-bucket-redis" &>/dev/null; then
  flyctl redis create \
    --name msr-bucket-redis \
    --plan Free \
    --region lax \
    --no-replicas \
    --disable-eviction >redis.txt
fi

if ! flyctl postgres list | grep "msr-bucket-postgres" &>/dev/null; then
  flyctl postgres create \
    --name msr-bucket-postgres \
    --initial-cluster-size 1 \
    --vm-size shared-cpu-1x \
    --volume-size 1 \
    --region lax >postgres.txt
fi

if ! flyctl apps list | grep "msr-bucket-nextcloud" &>/dev/null; then
  flyctl launch \
    --name msr-bucket-nextcloud \
    --region lax \
    --no-deploy
  rm fly.toml
  flyctl postgres attach \
    msr-bucket-postgres \
    --app msr-bucket-nextcloud \
    --database-user nextcloud \
    --database-name nextcloud \
    --force >db.txt
fi

# set some app secrets

flyctl deploy \
  --app msr-bucket-nextcloud \
  --image nextcloud \
  --now

App is deployed at https://msr-bucket-nextcloud.fly.dev/, and currently showing 502 status after waiting for couple of minutes in loading state. Can anyone guide me to how I can fix it please? Thanks in advance.

Maybe it’s because the underlying proxy server doesn’t know where to forward the incoming HTTP requests.