Search code examples
postgresqldockerdocker-composemetabase

Metabase + PostgresSQL on Docker - "Unauthenticated" error


Used docker compose for metabase and postgres images.

Managed to build successfully. Went through the Metabase setup, no hitches.

However, I can't seem to get past the sign in page. Each time I enter the correct username and password I used at the setup stage, it still returns me to the sign in page.

Checking the docker logs, I keep seeing this error on sign in attempts:

2022-09-24 23:24:31,502 DEBUG middleware.log :: GET /api/user/current 401 320.3 µs (0 DB calls)
"Unauthenticated"

Not sure what could be wrong?


Solution

  • Turns out the answer had nothing at all to do with Metabase or Docker, but with my Nginx configuration

    Problem was in my location block. Initial settings were:

        location / {
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-Host $host;
          proxy_set_header X-Forwarded-Proto https;
          proxy_pass http://localhost:<some_port>;  # <- put correct port
      }
    

    Changed them to

        location / {
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-Host $host;
          proxy_set_header X-Forwarded-Proto $scheme;   # <- *changed to this*
          proxy_pass http://localhost:<some_port>;  # <- put correct port
          proxy_http_version 1.1;   # <- *add this*
      }
    

    ...and the error was gone: can log in now.