Grist-Omnibus not working with external reverse proxy with 419/502 error

I am trying to configure grist-omnibus and am running into SSL issues. This docker compose works perfectly, but it does not include SSL. Even though I am running Grist on my LAN, I prefer SSL. Scroll further down to see the SSL config.:

name: Grist
services:
    grist-omnibus:
        ports:
            - 9999:80
        environment:
            - URL=http://<localip>:9999
            - TEAM=home
            - EMAIL=<email>
            - PASSWORD=<Password>
        volumes:
            - /opt/grist:/persist
        container_name: grist
        stdin_open: true
        tty: true
        image: gristlabs/grist-omnibus:latest

I use Nginx Proxy Manager in my Homelab, and it works perfectly for everything I throw at it. Naturally I decided to use it with Grist so started with the compose file below.

name: Grist
services:
    grist-omnibus:
        ports:
            - 9999:80
        environment:
            - URL=https://<FQDN IP>
            - TEAM=home
            - EMAIL=<email>
            - PASSWORD=<Password>
            - HTTPS=external
            - TRUSTED_PROXY_IPS=<Proxy IP>
        volumes:
            - /opt/grist:/persist
        container_name: grist
        stdin_open: true
        tty: true
        image: gristlabs/grist-omnibus:latest

The problem is that Grist refuses to run. When I run “docker compose up”, I see the following error message repeating repeatedly. What am I doing wrong? Do I need some kind of redirect in NPM?

grist | info [grist-omnibus] Checking dex… at https://Local FQDN/dex/.well-known/openid-configuration
grist | debug [grist-omnibus] got: 418

Update, AI suggested adding this to the advanced options in NPM. The error changes to 502.

location /dex/.well-known/ {
    proxy_pass http://<Private IP>;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

Thank you in advance for any advice!