iFargle / headscale-webui

A simple Headscale web UI for small-scale deployments.
Other
627 stars 57 forks source link

Error - /data not writable #72

Closed threerog closed 1 year ago

threerog commented 1 year ago
Error - /data not writable
/data is not writable. Please ensure your permissions are correct. /data mount should be writable by UID/GID 1000:1000.
version: "3"
services:
  headscale-webui:
    image: ghcr.io/ifargle/headscale-webui:latest
    container_name: headscale-webui
    network_mode: host
    environment:
      - TZ=Asia/Shanghai
      - COLOR=red 
      - HS_SERVER=http://0.0.0.0:8080
      - DOMAIN_NAME=http://0.0.0.0:5000 
      - SCRIPT_NAME=/admin
      - KEY="PSDSzZAXi0UTtod8oQEO/13u8EK0oR+PjB+h2+XUtWI="
      - AUTH_TYPE=basic
      - LOG_LEVEL=info
      - BASIC_AUTH_USER=admin
      - BASIC_AUTH_PASS=admin
    volumes:
      - /etc/headscale/ui:/data:rw
      - /etc/headscale/config:/etc/headscale:ro
threerog commented 1 year ago
[2023-04-03 07:47:50,770] CRITICAL in helper: /data WRITE: FAILED
[2023-04-03 07:47:50,770] ERROR in helper: /data/key.txt EXIST: FAILED - NO ERROR

Does this key.txt need to be created manually If you need to create it manually, what content is in it

iFargle commented 1 year ago

It should be redirecting you to the settings page to put your key in.

iFargle commented 1 year ago

technically not an error unless you've already tried putting your key in on the Settings page. I'll fix the code so it just shows as INFO.

iFargle commented 1 year ago

Oh I didn't see the first part. /data is not writable. Please ensure your permissions are correct. /data mount should be writable by UID/GID 1000:1000.

You'll need to set whatever mount /data is on to 1000:1000 with chown

threerog commented 1 year ago

Oh I didn't see the first part. /data is not writable. Please ensure your permissions are correct. /data mount should be writable by UID/GID 1000:1000.

You'll need to set whatever mount /data is on to 1000:1000 with chown

sudo chown 1000:1000 /data
mount | grep "/data"

I tried to execute the above command as root, which is still 4096

iFargle commented 1 year ago

Are you running this inside or outside the container? The folder outside the container should be 1000:1000

iFargle commented 1 year ago

In this case, chown 1000:1000 /etc/headscale/ui

threerog commented 1 year ago

Thank you. In addition, I would like to ask if the headscale configuration directory must be under the root directory? /headscale/config

I want to place all the headscale configuration files in /etc/headscale/config How to write a volume

/etc/headscale/ui
/etc/headscale/config/private.key
/etc/headscale/config/noise_private.key
/etc/headscale/config/db.sqlite

This is my modified docker-compose.yml But it doesn't work

docker run \
  --name headscale \
  --detach \
  --volume /etc/headscale/config:/etc/headscale/config \
  --publish 0.0.0.0:8080:8080 \
  --publish 0.0.0.0:9090:9090 \
  headscale/headscale:latest \
  headscale serve

logs

WRN Failed to read configuration from disk error="Config File \"config\" Not Found in \"[/etc/headscale /root/.headscale /]\""
FTL go/src/headscale/cmd/headscale/cli/root.go:48 > Error loading config error="fatal error reading config file: Config File \"config\" Not Found in \"[/etc/headscale /root/.headscale /]\""
threerog commented 1 year ago

Thank you again. I've already solved it

threerog commented 1 year ago

Is apikey the environment parameter KEY for headscale-ui

Error
Key authentication failed. Check your key.
[2023-04-03 09:27:36,316] ERROR in helper: /data/key.txt EXIST: FAILED - NO ERROR
[2023-04-03 09:27:36,316] INFO in helper: All startup checks passed.
[2023-04-03 09:27:36,316] INFO in helper: Testing API key validity.
[2023-04-03 09:27:36,317] INFO in helper: Got a non-200 response from Headscale.  Test failed (Response:  500)
[2023-04-03 09:28:07 +0800] [1] [CRITICAL] WORKER TIMEOUT (pid:8)
iFargle commented 1 year ago

There are two "keys":

  1. Your Headscale API key, generated with headscale apikeys create on your Headscale server
  2. Your KEY environment variable, generated with openssl rand -base64 32

the KEY variable is used to encrypt your Headscale API key when it's written to disk (via the "Save" button on the Settings page)

You enter your Headscale API key on the Settings page, click Save, then click Test to verify it works.

iFargle commented 1 year ago

Key in that error message refers to your Headscale API key. You'll need to save THEN test :)

threerog commented 1 year ago

Finally working properly Two summary points are the chown 1000:1000 permission issue and the headscale apikeys create

iFargle commented 1 year ago

Good to know! I'll make some changes to the README to make this a bit more clear!