linuxserver / docker-healthchecks

GNU General Public License v3.0
177 stars 38 forks source link

[BUG] CSRF_TRUSTED_ORIGINS #104

Closed p6002 closed 1 year ago

p6002 commented 1 year ago

Is there an existing issue for this?

Current Behavior

Does anyone have a working compose for this tool? I've been trying to get it running for a few hours and there is no way to do so.

https://pastebin.com/kRPbbXTf

Expected Behavior

Working container

Steps To Reproduce

Starting container.

Environment

- OS: Ubuntu Server 22 VM
- How docker service was installed: standard instalation via cli.

CPU architecture

x86-64

Docker creation

version: "2.1"
services:
  healthchecks:
    image: lscr.io/linuxserver/healthchecks:latest
    container_name: healthchecks
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Amsterdam
      - SITE_ROOT=https://healthchecks.my.domain/
      - SITE_NAME=HealthChecks

      - DEFAULT_FROM_EMAIL=test@my.domain
      - EMAIL_HOST=smtp.gmail.com
      - EMAIL_PORT=587 # 465 or 587
      - EMAIL_HOST_USER=test@my.domain
      - EMAIL_HOST_PASSWORD=pass
      - EMAIL_USE_TLS=True # True or False
      - SUPERUSER_EMAIL=user@my.domain
      - SUPERUSER_PASSWORD=pass

      #- REGENERATE_SETTINGS= #optional
      #- ALLOWED_HOSTS= #optional
      - APPRISE_ENABLED=True # True or False
      - DEBUG=False #optional
      #- INTEGRATIONS_ALLOW_PRIVATE_IPS= #optional
      #- PING_EMAIL_DOMAIN= #optional
      #- SECRET_KEY= #optional
      #- SITE_LOGO_URL= #optional
    volumes:
      - /docker/healthchecks:/config
    ports:
      - 2626:8000
      - 2525:2525 #optional
    restart: unless-stopped

    networks:
      - traefik_default
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.healthchecks.entrypoints=web, websecure"
      - "traefik.http.routers.healthchecks.tls=true"
      - "traefik.http.routers.healthchecks.tls.certresolver=production"
      - "traefik.http.routers.healthchecks.rule=Host(`healthchecks.my.domain`)"

networks:
  traefik_default:
    external:
      name: traefik_default

Container logs

[migrations] started
[migrations] no migrations found
───────────────────────────────────────
      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 
   Brought to you by linuxserver.io
───────────────────────────────────────
To support LSIO projects visit:
https://www.linuxserver.io/donate/
───────────────────────────────────────
GID/UID
───────────────────────────────────────
User UID:    1000
User GID:    1000
───────────────────────────────────────
SystemCheckError: System check identified some issues:
ERRORS:
?: (4_0.E001) As of Django 4.0, the values in the CSRF_TRUSTED_ORIGINS setting must start with a scheme (usually http:// or https://) but found . See the release notes for details.
SystemCheckError: System check identified some issues:
ERRORS:
?: (4_0.E001) As of Django 4.0, the values in the CSRF_TRUSTED_ORIGINS setting must start with a scheme (usually http:// or https://) but found . See the release notes for details.
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python3.10/site-packages/django/db/backends/sqlite3/base.py", line 357, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: auth_user
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/app/healthchecks/manage.py", line 17, in <module>
    raise e
  File "/app/healthchecks/manage.py", line 13, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3.10/site-packages/django/core/management/commands/shell.py", line 127, in handle
    exec(sys.stdin.read(), globals())
  File "<string>", line 7, in <module>
  File "/usr/lib/python3.10/site-packages/django/db/models/query.py", line 621, in count
    return self.query.get_count(using=self.db)
  File "/usr/lib/python3.10/site-packages/django/db/models/sql/query.py", line 559, in get_count
    return obj.get_aggregation(using, ["__count"])["__count"]
  File "/usr/lib/python3.10/site-packages/django/db/models/sql/query.py", line 544, in get_aggregation
    result = compiler.execute_sql(SINGLE)
  File "/usr/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1398, in execute_sql
    cursor.execute(sql, params)
  File "/usr/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "/usr/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/usr/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python3.10/site-packages/django/db/backends/sqlite3/base.py", line 357, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: auth_user
s6-rc: warning: unable to start service init-healthchecks-config: command exited 1
github-actions[bot] commented 1 year ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

thespad commented 1 year ago

Yeah it needs a proper fix since django 4.0 requires the CSRF_TRUSTED_ORIGINS but our init doesn't support it properly at the moment and I haven't had time to PR a fix.

You can directly add it to the local_settings.py in /config, however.

CSRF_TRUSTED_ORIGINS = ["https://healthchecks.example.com"]
p6002 commented 1 year ago

Thanks, now it works. I still had to deactivate ports 2525 to get traefik to let traffic through to the correct port.