iFargle / headscale-webui

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

Internal Server Error on /routes #69

Closed ngreenwood6 closed 1 year ago

ngreenwood6 commented 1 year ago

It looks like the feature to view the routes was just added which is awesome. However, when I try to view the page it just gives an "Internal Server Error". The docker logs show the following:

[2023-04-01 01:59:28,796] ERROR in app: Exception on /routes [GET]
Traceback (most recent call last):
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 131, in decorated
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 183, in routes_page
    render_page       = renderer.render_routes(),
                        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/renderer.py", line 799, in render_routes
    if all_routes["routes"][int(route_id) - 1]["enabled"]: failover_display = failover_enabled
       ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
IndexError: list index out of range
iFargle commented 1 year ago

Can you give me the output of the routes ls command on your Headscale servers? headscale routes ls

iFargle commented 1 year ago

All my routes are ordered but I'm not sure it's the correct way to do it.. So I just take the route ID and subtract 1 for the index in the array. It's likely you have deleted routes or something so the index is "wrong"

ngreenwood6 commented 1 year ago

Yeah I definitely have been messing around and removed routes. Here is the output:

ID | Machine    | Prefix          | Advertised | Enabled | Primary
3  | alex-pc    | 0.0.0.0/0       | false      | false   | -      
4  | alex-pc    | ::/0            | false      | false   | -      
13 | dev-server | 192.168.1.0/24  | true       | true    | true   
18 |            | 192.168.99.0/24 | true       | false   | false  
19 |            | 192.168.99.0/24 | true       | false   | false  
20 |            | 192.168.99.0/24 | true       | false   | false  
21 |            | 192.168.99.0/24 | true       | false   | false  
22 | pfsense    | 192.168.96.0/19 | true       | true    | true   
23 |            | 0.0.0.0/0       | true       | true    | -      
24 |            | ::/0            | true       | true    | -    
ngreenwood6 commented 1 year ago

After looking at this I also noticed that by removing machines that I setup those routes on it didn't remove the routes. Shouldn't it be removing those routes when the machine is removed? I am not sure if this is a "UI" issue or an "API" issue. Maybe I should put this on the head scale repo?

iFargle commented 1 year ago

Its a pre-v0.21.0 Headscale issue. The latest version fixes it for everything except ephemeral nodes timing out

On April 1, 2023 3:05:37 PM UTC, ngreenwood6 @.***> wrote:

After looking at this I also noticed that by removing machines that I setup those routes on it didn't remove the routes. Shouldn't it be removing those routes when the machine is removed? I am not sure if this is a "UI" issue or an "API" issue. Maybe I should put this on the head scale repo?

-- Reply to this email directly or view it on GitHub: https://github.com/iFargle/headscale-webui/issues/69#issuecomment-1492999253 You are receiving this because you were assigned.

Message ID: @.> -- Albert J. Copeland @. PGP Fingerprint:  64F6C4EB46C4543A

iFargle commented 1 year ago

I need to rewrite my code to get this working properly. Sorry about that. I'll work on it when I have time :).

On April 1, 2023 3:03:06 PM UTC, ngreenwood6 @.***> wrote:

Yeah I definitely have been messing around and removed routes. Here is the output:

ID | Machine    | Prefix          | Advertised | Enabled | Primary
3  | alex-pc    | 0.0.0.0/0       | false      | false   | -      
4  | alex-pc    | ::/0            | false      | false   | -      
13 | dev-server | 192.168.1.0/24  | true       | true    | true   
18 |            | 192.168.99.0/24 | true       | false   | false  
19 |            | 192.168.99.0/24 | true       | false   | false  
20 |            | 192.168.99.0/24 | true       | false   | false  
21 |            | 192.168.99.0/24 | true       | false   | false  
22 | pfsense    | 192.168.96.0/19 | true       | true    | true   
23 |            | 0.0.0.0/0       | true       | true    | -      
24 |            | ::/0            | true       | true    | -    

-- Reply to this email directly or view it on GitHub: https://github.com/iFargle/headscale-webui/issues/69#issuecomment-1492998411 You are receiving this because you were assigned.

Message ID: @.> -- Albert J. Copeland @. PGP Fingerprint:  64F6C4EB46C4543A

iFargle commented 1 year ago

Actually that may have been an easier fix than I thought. Can you pull ghcr.io/ifargle/headscale-webui:testing and give it a shot? if this works I'll move it into main :)

ngreenwood6 commented 1 year ago

It looks like its still happening. I am getting the following:

[2023-04-01 20:45:02,295] INFO in renderer: Rendering Routes page
[2023-04-01 20:45:02,295] INFO in headscale: Getting routes
[2023-04-01 20:45:02,400] INFO in renderer: Found route 3 / machine: Alex-PC
[2023-04-01 20:45:02,400] INFO in renderer: Found route 4 / machine: Alex-PC
[2023-04-01 20:45:02,400] INFO in renderer: Found route 13 / machine: dev-server
[2023-04-01 20:45:02,400] INFO in renderer: Route id 18 has no machine associated. Skipping
[2023-04-01 20:45:02,400] INFO in renderer: Route id 19 has no machine associated. Skipping
[2023-04-01 20:45:02,400] INFO in renderer: Route id 20 has no machine associated. Skipping
[2023-04-01 20:45:02,400] INFO in renderer: Route id 21 has no machine associated. Skipping
[2023-04-01 20:45:02,400] INFO in renderer: Found route 22 / machine: pfSense
[2023-04-01 20:45:02,400] INFO in renderer: Route id 23 has no machine associated. Skipping
[2023-04-01 20:45:02,400] INFO in renderer: Route id 24 has no machine associated. Skipping
[2023-04-01 20:45:02,400] ERROR in app: Exception on /routes [GET]
Traceback (most recent call last):
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 131, in decorated
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 183, in routes_page
    render_page       = renderer.render_routes(),
                        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/renderer.py", line 808, in render_routes
    current_route_index = all_routes_id_list.index(route_id)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: '18' is not in list
iFargle commented 1 year ago

18 | | 192.168.99.0/24 | true | false | false Let me do one more fix. This will still display empty routes but at least it won't error out :)

iFargle commented 1 year ago

(For now, you'll need to manually delete the routes through Headscale's CLI, my UI doesn't have a way of deleting routes, just enabling/disabling)

Try pulling a new build on testing. It should display now

ngreenwood6 commented 1 year ago

Just wanted to let you know on the latest the page is working. Thanks for the quick response.

DrShurii commented 10 months ago

WebUI Internal Server Error:

getting the below error :

headscale-webui | [2023-10-22 14:25:04,859] INFO in helper: All startup checks passed. headscale-webui | [2023-10-22 14:25:04,860] ERROR in app: Exception on / [GET] headscale-webui | Traceback (most recent call last): headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 133, in _verify_signature headscale-webui | h.verify(data[-32:]) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/hmac.py", line 70, in verify headscale-webui | ctx.verify(signature) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/hazmat/backends/openssl/hmac.py", line 84, in verify headscale-webui | raise InvalidSignature("Signature did not match digest.") headscale-webui | cryptography.exceptions.InvalidSignature: Signature did not match digest. headscale-webui | headscale-webui | During handling of the above exception, another exception occurred: headscale-webui | headscale-webui | Traceback (most recent call last): headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app headscale-webui | response = self.full_dispatch_request() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request headscale-webui | rv = self.handle_user_exception(e) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request headscale-webui | rv = self.dispatch_request() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request headscale-webui | return self.ensure_sync(self.view_functions[rule.endpoint])(*view_args) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/server.py", line 114, in decorated headscale-webui | return view_func(args, **kwargs) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/server.py", line 141, in overview_page headscale-webui | pass_checks = str(helper.load_checks()) headscale-webui | ^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/helper.py", line 301, in load_checks headscale-webui | if not key_check(): return 'settings_page' headscale-webui | ^^^^^^^^^^^ headscale-webui | File "/app/helper.py", line 58, in key_check headscale-webui | api_key = headscale.get_api_key() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/headscale.py", line 66, in get_api_key headscale-webui | decrypted_key = fernet.decrypt(enc_api_key).decode() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 90, in decrypt headscale-webui | return self._decrypt_data(data, timestamp, time_info) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 151, in _decrypt_data headscale-webui | self._verify_signature(data) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 135, in _verify_signature headscale-webui | raise InvalidToken headscale-webui | cryptography.fernet.InvalidToken headscale-webui | [2023-10-22 14:25:04 -0400] [8] [ERROR] Error handling request /favicon.ico headscale-webui | Traceback (most recent call last): headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 136, in handle headscale-webui | self.handle_request(listener, req, client, addr) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 169, in handle_request headscale-webui | resp, environ = wsgi.create(req, client, addr, headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/http/wsgi.py", line 183, in create headscale-webui | path_info = path_info.split(script_name, 1)[1] headscale-webui | ~~~~~~~^^^ headscale-webui | IndexError: list index out of range

MartinJohannesNilsen commented 6 months ago

WebUI Internal Server Error:

getting the below error :

headscale-webui | [2023-10-22 14:25:04,859] INFO in helper: All startup checks passed. headscale-webui | [2023-10-22 14:25:04,860] ERROR in app: Exception on / [GET] headscale-webui | Traceback (most recent call last): headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 133, in _verify_signature headscale-webui | h.verify(data[-32:]) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/hmac.py", line 70, in verify headscale-webui | ctx.verify(signature) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/hazmat/backends/openssl/hmac.py", line 84, in verify headscale-webui | raise InvalidSignature("Signature did not match digest.") headscale-webui | cryptography.exceptions.InvalidSignature: Signature did not match digest. headscale-webui | headscale-webui | During handling of the above exception, another exception occurred: headscale-webui | headscale-webui | Traceback (most recent call last): headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app headscale-webui | response = self.full_dispatch_request() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request headscale-webui | rv = self.handle_user_exception(e) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request headscale-webui | rv = self.dispatch_request() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request headscale-webui | return self.ensure_sync(self.view_functions[rule.endpoint])(*view_args) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/server.py", line 114, in decorated headscale-webui | return view_func(args, **kwargs) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/server.py", line 141, in overview_page headscale-webui | pass_checks = str(helper.load_checks()) headscale-webui | ^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/helper.py", line 301, in load_checks headscale-webui | if not key_check(): return 'settings_page' headscale-webui | ^^^^^^^^^^^ headscale-webui | File "/app/helper.py", line 58, in key_check headscale-webui | api_key = headscale.get_api_key() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/headscale.py", line 66, in get_api_key headscale-webui | decrypted_key = fernet.decrypt(enc_api_key).decode() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 90, in decrypt headscale-webui | return self._decrypt_data(data, timestamp, time_info) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 151, in _decrypt_data headscale-webui | self._verify_signature(data) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 135, in _verify_signature headscale-webui | raise InvalidToken headscale-webui | cryptography.fernet.InvalidToken headscale-webui | [2023-10-22 14:25:04 -0400] [8] [ERROR] Error handling request /favicon.ico headscale-webui | Traceback (most recent call last): headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 136, in handle headscale-webui | self.handle_request(listener, req, client, addr) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 169, in handle_request headscale-webui | resp, environ = wsgi.create(req, client, addr, headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/http/wsgi.py", line 183, in create headscale-webui | path_info = path_info.split(script_name, 1)[1] headscale-webui | ~~~~~~~^^^ headscale-webui | IndexError: list index out of range

I get a similar one myself:

[2024-02-15 16:04:17 +0000] [55786] [ERROR] Error handling request /
Traceback (most recent call last):
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 136, in handle
    self.handle_request(listener, req, client, addr)
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 169, in handle_request
    resp, environ = wsgi.create(req, client, addr,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/http/wsgi.py", line 183, in create
    path_info = path_info.split(script_name, 1)[1]
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
[2024-02-15 16:04:17 +0000] [55786] [ERROR] Error handling request /favicon.ico
Traceback (most recent call last):
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 136, in handle
    self.handle_request(listener, req, client, addr)
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 169, in handle_request
    resp, environ = wsgi.create(req, client, addr,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/http/wsgi.py", line 183, in create
    path_info = path_info.split(script_name, 1)[1]