Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not connect to Pocketbase #102

Open
v1r0x opened this issue May 2, 2024 · 10 comments
Open

Could not connect to Pocketbase #102

v1r0x opened this issue May 2, 2024 · 10 comments
Assignees

Comments

@v1r0x
Copy link

v1r0x commented May 2, 2024

Describe the bug

  • Grimoire instance webpage shows Could not connect to Pocketbase on https://grimoire.mydomain.de/pb. Is it running?.
  • Browser's dev console shows 404 in health check (GET https://grimoire.mydomain.de/internal/pb/api/health [HTTP/2 404 295ms])

To Reproduce
Steps to reproduce the behavior:

  1. Setup docker container with traefik reverse proxy (similar to Standalone Traefik reverse proxy & 405 Method Not Allowed #68 ) with pocketbae host label set to "traefik.http.routers.pocketbase.rule=Host(grimoire.mydomain.de) && PathPrefix(/pb/)".
  2. Set PUBLIC_POCKETBASE_URL=https://grimoire.mydomain.de/pb
  3. Start docker container and goto https://grimoire.mydomain.de
  4. Error on webpage and dev console is shown

Expected behavior
Webpage shoul dbe reachable without errors.
Also I'm confused why the health check url contains internal/?

Additional context
This issue might be related to #68 and #97, but I didn't want to "hijack" these issues. Feel free to close this as duplicate if I should continue in one of them :)

@goniszewski goniszewski self-assigned this May 3, 2024
@goniszewski
Copy link
Owner

Hello @v1r0x!

The latest version contains multiple fixes, one related to this exact issue, please check https://github.com/goniszewski/grimoire/releases/tag/v0.3.5!

Also I'm confused why the health check url contains internal/?

A: This is Grimoire's proxy path that is proxied internally to the default Pocketbase instance. Thus, we can keep all the API calls in the app itself and not via an external connection.

I'll keep this issue open and wait for your confirmation if it's fixed for you in the latest version!

@v1r0x
Copy link
Author

v1r0x commented May 3, 2024

Hello @goniszewski

Thanks for your fast reply. I already tried that version after it came out 😉

Edit: Is it enough to run docker-compose pull? Or should I checkout the git repo again?

Maybe I did something wrong with my setup? I'm far from an expert in docker or traefik 😀

Here's my docker-compose.yml

version: '3.7'
services:
  pocketbase:
    image: spectado/pocketbase:0.22.10
    container_name: grimoire-pocketbase
    restart: unless-stopped
    ports:
      - '8090:80'
    volumes:
      - pb_data:/pb_data
      - pb_migrations:/pb_migrations/
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:80/api/health || exit 1
      interval: 5s
      timeout: 5s
      retries: 5
    env_file: .env
    depends_on:
      - grimoire
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      # PocketBase
      - "traefik.http.routers.pocketbase.entrypoints=http"
      - "traefik.http.routers.pocketbase.rule=Host(`grimoire.mydomain.de`) && PathPrefix(`/pb/`)"
      - "traefik.http.middlewares.pocketbase.stripprefix.prefixes=/pb"
      - "traefik.http.middlewares.pocketbase-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.pocketbase.middlewares=pocketbase"
      - "traefik.http.routers.pocketbase.middlewares=pocketbase-https-redirect"
      - "traefik.http.routers.pocketbase-secure.entrypoints=https"
      - "traefik.http.routers.pocketbase-secure.rule=Host(`grimoire.mydomain.de`) && PathPrefix(`/pb/`)"
      - "traefik.http.routers.pocketbase-secure.tls=true"
      - "traefik.http.routers.pocketbase-secure.tls.certresolver=http"
      - "traefik.http.routers.pocketbase-secure.service=pocketbase"
      - "traefik.http.services.pocketbase.loadbalancer.server.port=80"
      - "traefik.docker.network=proxy"
  grimoire:
    image: goniszewski/grimoire:latest
    container_name: grimoire
    restart: unless-stopped
    env_file: .env
    volumes:
      - pb_migrations:/app/pb_migrations/
    build:
      context: .
      dockerfile: Dockerfile
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:$PORT/api/health || exit 1
      interval: 5s
      timeout: 5s
      retries: 5
    ports:
      - '$PORT:$PORT'
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.grimoire.entrypoints=http"
      - "traefik.http.routers.grimoire.rule=Host(`grimoire.mydomain.de`)"
      - "traefik.http.middlewares.grimoire-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.grimoire.middlewares=grimoire-https-redirect"
      - "traefik.http.routers.grimoire-secure.entrypoints=https"
      - "traefik.http.routers.grimoire-secure.rule=Host(`grimoire.mydomain.de`)"
      - "traefik.http.routers.grimoire-secure.tls=true"
      - "traefik.http.routers.grimoire-secure.tls.certresolver=http"
      - "traefik.http.routers.grimoire-secure.service=grimoire"
      - "traefik.http.services.grimoire.loadbalancer.server.port=5173"
      - "traefik.docker.network=proxy"

networks:
  proxy:
    external: true
volumes:
  pb_data:
  pb_migrations:

and .env

# Set it if you're using external PocketBase installation (default: http://pocketbase)
PUBLIC_POCKETBASE_URL=https://grimoire.mydomain.de/pb
ROOT_ADMIN_EMAIL=me@mydomain.de
ROOT_ADMIN_PASSWORD=password
PUBLIC_ORIGIN=https://grimoire.mydomain.de
PUBLIC_HTTPS_ONLY=true
PORT=5173
PUBLIC_SIGNUP_DISABLED=true

@goniszewski
Copy link
Owner

I've checked again the configuration you've provided. I do not have a single suspect, but rather a couple of ideas, so please bear with me:

  1. Did you check this configuration while using PUBLIC_POCKETBASE_URL without any value after =? It should then default to http://pocketbase
  2. Are you able to get to the app container and check related logs? The internal proxy may be to blame, and if it's true, then we can possibly have some logs to further investigate
  3. And there's the Origin, aka PUBLIC_ORIGIN env that, if not matching request's origin, can lead to CORS errors

Sorry I kept you waiting for so long!

@v1r0x
Copy link
Author

v1r0x commented May 14, 2024

Sorry I kept you waiting for so long!

No problem at all! ❤️ Really appreciate your help!

Is there a specific log file inside the container? docker-compose logs doesn't log much. (couldn't find anything related to internal log files)

@v1r0x
Copy link
Author

v1r0x commented May 15, 2024

I left PUBLIC_POCKETBASE_URL empty and now the initial error is gone! 🎉

BUT
When trying to add a new user and I click on "Sign up" nothing happens in the browser, but in the JS console/docker logs I get this error:

grimoire             | {
grimoire             |   invalid: true,
grimoire             |   settings: {
grimoire             |     code: 'validation_json_size_limit',
grimoire             |     message: 'The maximum allowed JSON size is 0 bytes.'
grimoire             |   }
grimoire             | }

@goniszewski
Copy link
Owner

What value do you have in your .env for BODY_SIZE_LIMIT?

@v1r0x
Copy link
Author

v1r0x commented May 15, 2024

I didn't set anything, but I tried to set it to the value from your Dockerfile. Still the same error with 0 bytes

@goniszewski
Copy link
Owner

Strange. Looks more like a proxy issue that is not directly related to the app itself.

@v1r0x
Copy link
Author

v1r0x commented May 19, 2024

Ok, thanks for the info. Then I'll dig into traefik to find my problem. Should I keep this issue open? Feel free to close it :) I'll add a new comment when I fixed my problem

@goniszewski
Copy link
Owner

It's OK to left it open. I hope you will stumble upon a solution to this problem and share it with us!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants