Hedgedoc behind swag: 502 bad gateway

Hi,
I’m trying to set up hedgedoc to run behind swag, but I run into a 502 bad gateway.
This is my docker-compose.
This is my hedgedoc.subdomain.conf.

The host machine is ubuntu 20.04, docker is version 1.5-2.

EDIT:
I found errors in hedgedoc log, so I made some adjustments, but couldn’t fix the issue.

Now my docker-compose is this.
My hedgedog log is full of this.
My mariadb2 log is this.
My swag log is this.

Thanks!

See here: SWAG setup - LinuxServer.io

Thanks, but I tried already :slight_smile:

  • I think they are all on the same network (“default”)
  • I think the container names match
  • I didn’t change the ports (aside from the second mariadb, which I think I had to change because 3306 was already taken by the first one)
  • I don’t really understand the last point.

Default bridge network (if that’s what you’re using) doesn’t provide containers access to each other via container name as dns hostname.

Don’t define a network, let compose create and manage one

Okay, thanks. I commented out all the last two lines:

#networks:
#default:

But still the hedgedoc can’t find the database:
Hedgedoc log

Thanks for your patience :slight_smile:

DB_PORT in hedgehog env vars should be 3306, the internal port

Sorry, still can’t get it to work.
I guess this is because I have two mariadb containers running, and I can’t put them both to port 3306. I tried to put mariadb2 to port 3307, and that’s why I told hedgedoc to look there. I tried to change it to 3306 but that didn’t work.
Just to clarify, this is my current docker-compose.

Mapped ports are irrelevant. In this case, you don’t even need to host map any ports for mariadb2 as the connection will go through the docker network, not through the host.

Remove all instances of the following:

    networks:
     - default

Thanks, but still no connection to database.
docker-compose.yml
Hedgedoc log
Mariadb2 log

Are you wiping out the data in the hedgedoc config mount between each change?

No, I didn’t think of that.
But now I deleted the hedgedoc config:

$ docker-compose down
$ rm -rf ~/docker/data/hedgedoc
$ docker-compose up -d

And still no connection to database:

$ docker logs hedgedoc
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-envfile: executing...
[cont-init.d] 01-envfile: exited 0.
[cont-init.d] 10-adduser: executing...

-------------------------------------
          _         ()
         | |  ___   _    __
         | | / __| | |  /  \
         | | \__ \ | | | () |
         |_| |___/ |_|  \__/


Brought to you by linuxserver.io
-------------------------------------

To support LSIO projects visit:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------

User uid:    1000
User gid:    1000
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 30-config: executing...
[cont-init.d] 30-config: exited 0.
[cont-init.d] 90-custom-folders: executing...
[cont-init.d] 90-custom-folders: exited 0.
[cont-init.d] 99-custom-scripts: executing...
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-scripts: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
/bin/sh: 1: git: not found
2021-10-15T11:20:56.059Z warn:  Session secret not set. Using random generated one. Please set `sessionSecret` in your config.json file. All users will be logged out.
2021-10-15T11:20:56.547Z warn:  Database cannot be reached. Try 1 of 30.
2021-10-15T11:20:57.567Z warn:  Database cannot be reached. Try 2 of 30.
2021-10-15T11:20:58.585Z warn:  Database cannot be reached. Try 3 of 30.
2021-10-15T11:20:59.608Z warn:  Database cannot be reached. Try 4 of 30.
2021-10-15T11:21:00.628Z warn:  Database cannot be reached. Try 5 of 30.
2021-10-15T11:21:01.653Z warn:  Database cannot be reached. Try 6 of 30.
2021-10-15T11:21:02.672Z warn:  Database cannot be reached. Try 7 of 30.
2021-10-15T11:21:03.691Z warn:  Database cannot be reached. Try 8 of 30.
2021-10-15T11:21:04.708Z warn:  Database cannot be reached. Try 9 of 30.
2021-10-15T11:21:05.726Z warn:  Database cannot be reached. Try 10 of 30.
2021-10-15T11:21:06.746Z warn:  Database cannot be reached. Try 11 of 30.
2021-10-15T11:21:07.764Z warn:  Database cannot be reached. Try 12 of 30.
2021-10-15T11:21:08.782Z warn:  Database cannot be reached. Try 13 of 30.
2021-10-15T11:21:09.800Z warn:  Database cannot be reached. Try 14 of 30.
2021-10-15T11:21:10.819Z warn:  Database cannot be reached. Try 15 of 30.
2021-10-15T11:21:11.837Z warn:  Database cannot be reached. Try 16 of 30.
2021-10-15T11:21:12.855Z warn:  Database cannot be reached. Try 17 of 30.
2021-10-15T11:21:13.874Z warn:  Database cannot be reached. Try 18 of 30.
2021-10-15T11:21:14.893Z warn:  Database cannot be reached. Try 19 of 30.
2021-10-15T11:21:15.914Z warn:  Database cannot be reached. Try 20 of 30.
2021-10-15T11:21:16.931Z warn:  Database cannot be reached. Try 21 of 30.
2021-10-15T11:21:17.948Z warn:  Database cannot be reached. Try 22 of 30.
2021-10-15T11:21:18.967Z warn:  Database cannot be reached. Try 23 of 30.
2021-10-15T11:21:19.983Z warn:  Database cannot be reached. Try 24 of 30.
2021-10-15T11:21:21.002Z warn:  Database cannot be reached. Try 25 of 30.
2021-10-15T11:21:22.026Z warn:  Database cannot be reached. Try 26 of 30.
2021-10-15T11:21:23.046Z warn:  Database cannot be reached. Try 27 of 30.
2021-10-15T11:21:24.066Z warn:  Database cannot be reached. Try 28 of 30.
2021-10-15T11:21:25.082Z warn:  Database cannot be reached. Try 29 of 30.
2021-10-15T11:21:26.106Z error:         Cannot reach database! Exiting.
/bin/sh: 1: git: not found

Have you confirmed the mariadb is connectable? Tested with a SQL client of some sort?

When I opened the host port 3307 to the mariadb2 port 3306 and opened the host firewall port 3307 to local traffic (192.168.1.0/24), I could connect to it from my laptop:

$ mysql -h 192.168.1.100 -P 3307 -u hedgedoc -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.5.12-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

is there a database? when you login as hedgedoc, type show databases;

Yes, looks like it:

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| hedgedoc           |
| information_schema |
+--------------------+
2 rows in set (0.008 sec)

MariaDB [(none)]>