go-vikunja / vikunja

Mirror of vikunja from https://code.vikunja.io/api
GNU Affero General Public License v3.0
758 stars 55 forks source link

Problems with single-container version: 502, Migration failed, no live upstreams #247

Closed daniel86 closed 3 months ago

daniel86 commented 3 months ago

Description

I have problems updating to the latest docker version of vikunja, i.e. the one that merges API and frontend. I did not have time before, so was left with a broken instance for some time now. It was running nicely with the separate containers.

My setup involves nginx running on my host, and vikunja running in docker with docker-compose (with watchtower always keeping it up to date).

The issue is that I cannot connect to the frontend anymore. The browser reports a 502. Looking at the nginx log there are entries of the form:

[error] 965481#965481: *3477933 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: REDACTED, server: REDACTED, request: "GET /sw.js HTTP/2.0", upstream: "http://127.0.0.1:6080/sw.js", host: "REDACTED", referrer: "https://REDACTED/sw.js"

and

[error] 965491#965491: *3477595 no live upstreams while connecting to upstream, client: REDACTED, server: REDACTED, request: "GET /favicon.ico HTTP/2.0", upstream: "http://localhost/favicon.ico", host: "REDACTED", referrer: "https://REDACTED/"

The only error that appears in the vikunja logs is the following one:

2024-04-05T13:01:22.300862447+02:00: CRITICAL   ▶ migration/Migrate 003 Migration failed: dial tcp 172.28.0.2:3306: connect: connection refused

So before I had two sections in the docker-compose, which I merged into one:

  vikunja-db:
    image: mariadb:10
    restart: unless-stopped
    container_name: vikunja-db
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    networks:
      - tasks
    environment:
      MYSQL_ROOT_PASSWORD: "vikunja"
      MYSQL_USER: REDACTED
      MYSQL_PASSWORD: REDACTED
      MYSQL_DATABASE: REDACTED
    volumes:
      - ./vikunja/db:/var/lib/mysql

  vikunja:
    image: vikunja/vikunja
    restart: unless-stopped
    container_name: vikunja
    networks:
      - tasks
    environment:
      VIKUNJA_DATABASE_HOST: vikunja-db
      VIKUNJA_DATABASE_PASSWORD: REDACTED
      VIKUNJA_DATABASE_TYPE: mysql
      VIKUNJA_DATABASE_USER: REDACTED
      VIKUNJA_DATABASE_DATABASE: REDACTED
      VIKUNJA_SERVICE_JWTSECRET: REDACTED
      VIKUNJA_SERVICE_PUBLICURL: https://REDACTED/
      VIKUNJA_SERVICE_ENABLECALDAV: true
      VIKUNJA_SERVICE_ENABLEREGISTRATION: false
      VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: true
      VIKUNJA_SERVICE_TIMEZONE: "Europe/Berlin"
      VIKUNJA_METRICS_ENABLED: false
      VIKUNJA_MAILER_ENABLED: 1
      VIKUNJA_MAILER_FORCESSL: 1
      VIKUNJA_MAILER_HOST: "${EMAIL_HOST}"
      VIKUNJA_MAILER_PORT: "${EMAIL_PORT}"
      VIKUNJA_MAILER_USERNAME: "${EMAIL_HOST_USER}"
      VIKUNJA_MAILER_PASSWORD: "${EMAIL_HOST_PASSWORD}"
      VIKUNJA_MAILER_FROMEMAIL: "${EMAIL_DEFAULT_FROM}"
      VIKUNJA_API_URL: https://REDACTED/api/v1
      PUID: 1000
      PGID: 1000
      TZ: Europe/Berlin
    ports:
      - 3456:3456
      - 6080:80
    volumes:
      - ./vikunja/files:/app/vikunja/files
      - ./vikunja/config:/etc/vikunja
    depends_on:
      - vikunja-db

The nginx reverse proxy has following entry:

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name REDACTED;

    ssl_certificate /etc/letsencrypt/live/REDACTED/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/REDACTED/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;

    client_max_body_size 100M;
    charset utf-8;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    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;
    proxy_set_header X-Forwarded-Protocol $scheme;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_redirect off;

    location / {
        proxy_pass http://localhost:6080;
    }

    location ~* ^/(api|dav|\.well-known)/ {
        proxy_pass http://localhost:3456;
    }
}

I am a bit lost, any idea what is going wrong?

Vikunja Version

vikunja/vikunja:latest

Browser and version

No response

Can you reproduce the bug on the Vikunja demo site?

No

Screenshots

No response

daniel86 commented 3 months ago

It seems I got it working again with simplified entry for nginx:

    location / {
        proxy_pass http://localhost:3456;
    }