How to add vikunja apps on top of existing nginx reverse reverse proxy?

I think that the vikunja DB and the nginx proxy manager DB are clashing on port 3306, even though I tried to config the vikunja DB to go to 3307 instead.

This is all running on a QNAP NAS QTS 5 if that matters

Docker ps (minus some other irrelevant containers)


NTAINER ID   IMAGE                             COMMAND                  CREATED          STATUS                          PORTS                                                                  NAMES
ae21799b5a16   vikunja/api                       "/run.sh"                41 seconds ago   Restarting (1) 13 seconds ago                                                                          vikunja_vikunja_api_1
47b23f54ea42   vikunja/frontend                  "/docker-entrypoint.…"   43 seconds ago   Up 40 seconds                   0.0.0.0:8022->80/tcp                                                   vikunja_vikunja_frontend_1
924b06fb82d0   mariadb:10                        "docker-entrypoint.s…"   43 seconds ago   Up Less than a second           3306/tcp, 0.0.0.0:35302->3307/tcp                                      vikunja_vikunja_db_1
0b7b6e80fa97   jc21/mariadb-aria:latest          "/scripts/run.sh"        6 days ago       Up 6 days                       3306/tcp                                                               nginxproxymanager_db_1

Docker compose config:

version: '3'

services:
  vikunja_db:
    image: mariadb:10
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    ports: 
      - 35302:3307
    environment:
      MYSQL_ROOT_PASSWORD: supersecret
      MYSQL_USER: vikunja
      MYSQL_PASSWORD: secret
      MYSQL_DATABASE: vikunja
    volumes:
      - ./db:/var/lib/mysql
    restart: unless-stopped
  vikunja_api:
    image: vikunja/api
    environment:
      VIKUNJA_DATABASE_HOST: vikunja_db
      VIKUNJA_DATABASE_PASSWORD: secret
      VIKUNJA_DATABASE_TYPE: mysql
      VIKUNJA_DATABASE_USER: vikunja
      VIKUNJA_DATABASE_PORT: 3307
      VIKUNJA_DATABASE_DATABASE: vikunja
      VIKUNJA_SERVICE_FRONTENDURL: https://plan.trieu.cloud/
      VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: 1
      VIKUNJA_SERVICE_ENABLEREGISTRATION: 0
      VIKUNJA_SERVICE_ENABLEEMAILREMINDERS: 1
      VIKUNJA_MAILER_ENABLED: 1
      VIKUNJA_MAILER_FORCESSL: 1
      VIKUNJA_MAILER_HOST: smtp.gmail.com
      VIKUNJA_MAILER_PORT: 465
      VIKUNJA_MAILER_USERNAME: kunjamailer@gmail.com
      VIKUNJA_MAILER_PASSWORD: n2WrBFnZAzrttM
    volumes: 
      - ./files:/app/vikunja/files
    depends_on:
      - vikunja_db
    restart: unless-stopped
  vikunja_frontend:
    image: vikunja/frontend
    ports:
      - 8022:80
    restart: unless-stopped

networks:
  default:
    external: true
    name: nginxproxymanager_default

I know, I’m a total noob. How do I config this to stop messing with the other db?

You have a couple of options.

  1. Change the port the mariadb listens on. That’s what you tried to do, but you will need to tell mariadb that it should listen on port 3307 and not 3306. You’ll need a custom mariadb config for that. Check out the docs on docker hub for how to do this.
  2. Use postgres as a database for Vikunja. That runs on a different port and won’t collide with any other mariadb’s running in the same network.
  3. Make sure only one mariadb runs in the same network as Vikunja. You have the default network changed to the one of nginx proxy manager. I suppose to enable the proxy manager to talk to the api and frontend containers? Instead, try adding the nginx proxy manager network with a name other than default to the networks section of your compose file and then add the frontend and api containers to that network and the default network. The compose example for traefik 2 does this. Also check out the compose reference on networks.

The last option is the cleanest and most “docker way of doing things”.

Thanks for the help. I’m still not able to get it to work, but at least all the containers aren’t going haywire like before. I’m now getting some sort of redirect error


2021/11/07 08:10:54 [notice] 1#1: start worker process 28

2021/11/07 08:10:54 [notice] 1#1: start worker process 29

2021/11/07 08:10:54 [notice] 1#1: start worker process 30

2021/11/07 08:28:09 [error] 23#23: *1 rewrite or internal redirection cycle while internally redirecting to "/", client: 192.168.1.152, server: localhost, request: "GET / HTTP/1.1", host: "192.168.1.219:8022"

192.168.1.152 - - [07/Nov/2021:08:28:09 +0000] "GET / HTTP/1.1" 500 579 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36" "-"

2021/11/07 08:28:10 [error] 23#23: *2 rewrite or internal redirection cycle while internally redirecting to "/", client: 192.168.1.152, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.1.219:8022", referrer: "http://192.168.1.219:8022/"

192.168.1.152 - - [07/Nov/2021:08:28:10 +0000] "GET /favicon.ico HTTP/1.1" 500 579 "http://192.168.1.219:8022/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36" "-"

Here’s the compose yaml (deploying as a stack via portainer)

version: '3'

services:
  db:
    image: mariadb:10
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    environment:
      MYSQL_ROOT_PASSWORD: supersecret
      MYSQL_USER: vikunja
      MYSQL_PASSWORD: secret
      MYSQL_DATABASE: vikunja
    volumes:
      - /share/Apps/vikunja/db:/var/lib/mysql
    restart: unless-stopped
  api:
    image: vikunja/api
    environment:
      VIKUNJA_DATABASE_HOST: db
      VIKUNJA_DATABASE_PASSWORD: secret
      VIKUNJA_DATABASE_TYPE: mysql
      VIKUNJA_DATABASE_USER: vikunja
      VIKUNJA_DATABASE_DATABASE: vikunja
    volumes: 
      - /share/Apps/vikunja/files:/app/vikunja/files
    networks:
      - nginx-link
      - default    
    depends_on:
      - db
    restart: unless-stopped
  frontend:
    image: vikunja/frontend
    restart: unless-stopped
    networks:
      - nginx-link
      - default    
  proxy:
    image: nginx
    ports:
      - 8022:80
    volumes:
      - /share/Apps/vikunja/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - api
      - frontend
    restart: unless-stopped
    
networks:
  nginx-link:
    external: true

any ideas?

What’s the config from Vikunja’s nginx proxy container? What’s the config from nginx proxy manager for Vikunja?

Are those the logs from nginx proxy manager or Vikunja’s nginx proxy container?

Update:

I was able to get it by typing my hostip:8022!

Bad news is that the proxy manager is not forwarding correctly:
image

The previous errors were in the vikunja internal proxy btw. But they resolved after I updated my nginx.conf

it gets hung up when I try to hit it from the public address. “504 Gateway Time-out” openresty

Nothing noted in the nginx logs. in the vikunja internal nginx proxy i see this. Not sure if its bad though

192.168.1.152 - - [07/Nov/2021:14:10:55 +0000] "GET /api/v1/notifications?page=1 HTTP/1.1" 200 5 "http://192.168.1.219:8022/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36" "-"

192.168.1.152 - - [07/Nov/2021:14:11:05 +0000] "GET /api/v1/notifications?page=1 HTTP/1.1" 200 5 "http://192.168.1.219:8022/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36" "-"

192.168.1.152 - - [07/Nov/2021:14:11:15 +0000] "GET /api/v1/notifications?page=1 HTTP/1.1" 200 5 "http://192.168.1.219:8022/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36" "-"

Is nginx proxy manager running in docker as well? Then you need to use the ip or host name of Vikunja’s docker container.

You want to use a docker network for this. Check out the docs of nginx proxy manager: Advanced Configuration | Nginx Proxy Manager

Hi thanks so much for the replies and the help thus far, really appreciate it!

Yes, they are both in docker. I was somehow able to set up portainer like this (ie http://portainer:9000). but maybe its because portainer is on the nginxproxymanager_default network already?

The way I have vikunja set ups is I have a network bridge for containers: nginxproxymanager_app_1 and nginxproxymanager_db_1 to both be on two networks (set up via portainer) networks: nginxproxymanager_default and nginx_link

As for the vikunja stack:
containers: kunja_proxy and kunja_db are on the kunja_default network
containers: kunja_api_1 and kunja_frontend are on netwroks: kunja_default and nginx-link

I went back to re verse proxy manager to set the url to:
image

Still not sure where I’m going wrong.

Initially I didn’t have nginx_link and just had all containers default to nginxproxymanager_default but thats when the two maria dbs started stepping on each other.

My best guess for what I need to do next is to add the nginx-link network to the kunja_proxy container as well. But I’m slowly going mad and don’t want to ruin my actually working solution on (nashost):8022

I figured it out! had to delete the

ports:
  - 8022:80

Completely,

add the network nginx-link,

and set the proxy to http://kunja_proxy_1:80

'kunja_proxy_1" being the container name.

I wonder if the front end and the api server still need to be on nginx-link or just the proxy? well I’m not touching it for now. Happy that is its working.

1 Like

Glad you figured it out!

As long as the proxy container can talk to both the api and the frontend and you’re using nginx proxy manager to expose vikunja you should be good to go.