linuxserver / docker-webtop

Ubuntu, Alpine, Arch, and Fedora based Webtop images, Linux in a web browser supporting popular desktop environments.
GNU General Public License v3.0
1.68k stars 164 forks source link

[BUG] Webtop not working under reverse proxy (undefined is not an object evaluating UI.rfb.lastActiveAt #242

Open lamousis opened 2 months ago

lamousis commented 2 months ago

Is there an existing issue for this?

Current Behavior

I have installed webtop container (arm64 with alpine-mate tag) and it works fine on lan. Nut if I use it under my nginx reverse proxy I get this error KASMVNC encountered an error TypeError: undefined is not an object (evaluating UI.rfb.lastActiveAt) In the same nginx reverse proxy I also have filebrowser and jdowloader containers along with webtop and they are working fine. They are all in the same machine. The only problem comes with webtop, no matter what version I install This is my nginx.conf

`map $http_upgrade $connection_upgrade { default upgrade; '' close; }

upstream docker-jdownloader2 {
    # If the reverse proxy server is not running on the same machine as the
    # Docker container, use the IP of the Docker host here.
    # Make sure to adjust the port according to how port 5800 of the
    # container has been mapped on the host.
    server 172.17.0.4:5800;
}

upstream docker-webtop {
    server 172.17.0.5:3000;
}

server { listen 8443 ssl;

server_name localhost;

    server_name examplr.duckdns.org;
#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;
    ssl_certificate /etc/letsencrypt/live/example.duckdns.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.duckdns.org/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers  HIGH:!aNULL:!MD5;

    location / {
        root   html;
        index  index.html index.htm;
    }

    location /app1 {
        proxy_buffers 8 32k;
        proxy_buffer_size 64k;
        client_max_body_size 75M;
        proxy_pass http://172.17.0.3;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        #proxy_set_header X-NginX-Proxy true;

        # enables WS support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Forward-Proto $scheme;
        proxy_redirect off;
        proxy_read_timeout 999999999;
    }

    location = /jdownloader2 {return 301 $scheme://$http_host/jdownloader2/;}
    location /jdownloader2/ {
            proxy_pass http://docker-jdownloader2/;
            location /jdownloader2/websockify {
                    proxy_pass http://docker-jdownloader2/websockify/;
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection $connection_upgrade;
                    proxy_read_timeout 86400;
            }
    }

location = /webtop {return 301 $scheme://$http_host/webtop/;} location ^~ /webtop/ { proxy_pass http://docker-webtop/; location /webtop/websockify { proxy_pass http://docker-webtop/websockify; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
}`

Expected Behavior

It should load the webtop without any problem just like it does on lan

Steps To Reproduce

  1. Install arm64 alpine-mate container with docker-cli and run it through nginx reverse proxy
  2. With the above config of nginx I see the error mentioned

Environment

- OS:Ubuntu 22.04
- How docker service was installed:docker-cli following the instructions on linuxserver/webtop docker hub

CPU architecture

arm64

Docker creation

Using the instructions on linuxserver/webtop in docker hub

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:    1001
User GID:    1001
───────────────────────────────────────

[custom-init] No custom files found, skipping...
_XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.

Xvnc KasmVNC 1.2.0 - built Nov 25 2023 18:45:15
Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
See http://kasmweb.com for information on KasmVNC.
Underlying X server release 12014000, The X.Org Foundation

[ls.io-init] done.
[migrations] started
[migrations] no migrations found
usermod: no changes
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 

   Brought to you by linuxserver.io
───────────────────────────────────────

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

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    1001
User GID:    1001
───────────────────────────────────────

[custom-init] No custom files found, skipping...
_XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root

Xvnc KasmVNC 1.2.0 - built Nov 25 2023 18:45:15
Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
See http://kasmweb.com for information on KasmVNC.
Underlying X server release 12014000, The X.Org Foundation

[ls.io-init] done.
[migrations] started
[migrations] no migrations found
usermod: no changes
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 

   Brought to you by linuxserver.io
───────────────────────────────────────

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

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    1001
User GID:    1001
───────────────────────────────────────

[custom-init] No custom files found, skipping...
[ls.io-init] done.
_XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root

Xvnc KasmVNC 1.2.0 - built Nov 25 2023 18:45:15
Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
See http://kasmweb.com for information on KasmVNC.
Underlying X server release 12014000, The X.Org Foundation

[migrations] started
[migrations] no migrations found
usermod: no changes
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 

   Brought to you by linuxserver.io
───────────────────────────────────────

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

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    1001
User GID:    1001
───────────────────────────────────────

[custom-init] No custom files found, skipping...
_XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root

Xvnc KasmVNC 1.2.0 - built Nov 25 2023 18:45:15
Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
See http://kasmweb.com for information on KasmVNC.
Underlying X server release 12014000, The X.Org Foundation

[ls.io-init] done.
[migrations] started
[migrations] no migrations found
usermod: no changes
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 

   Brought to you by linuxserver.io
───────────────────────────────────────

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

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    1001
User GID:    1001
───────────────────────────────────────

[custom-init] No custom files found, skipping...
_XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root

Xvnc KasmVNC 1.2.0 - built Nov 25 2023 18:45:15
Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
See http://kasmweb.com for information on KasmVNC.
Underlying X server release 12014000, The X.Org Foundation

[ls.io-init] done.
[migrations] started
[migrations] no migrations found
usermod: no changes
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 

   Brought to you by linuxserver.io
───────────────────────────────────────

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

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    1001
User GID:    1001
───────────────────────────────────────

[custom-init] No custom files found, skipping...
_XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root

Xvnc KasmVNC 1.2.0 - built Nov 25 2023 18:45:15
Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
See http://kasmweb.com for information on KasmVNC.
Underlying X server release 12014000, The X.Org Foundation

[ls.io-init] done.
github-actions[bot] commented 2 months ago

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

j0nnymoe commented 2 months ago

Webtop works fine behind a reverse proxy, you need to make sure you're handling websockets correctly. We provide a proxy conf with our swag container you can use for reference: https://github.com/linuxserver/reverse-proxy-confs/blob/master/webtop.subdomain.conf.sample

lamousis commented 2 months ago

I got it working. Apparently it doesn't work with a subfolder (example.duckdns.org/webtop) but with the reverse proxy root itself (example.duckdns.org). Is the a way to work with subfolder? Every time in the location directive if I use location /webtop I get the ui.rfb.lastActiveAt error. Also in the nginx error log I get this 2024/05/06 20:16:33 [error] 2889#0: *523 open() "/usr/local/nginx/html/websockify" failed (2: No such file or directory), client: x.x.x.x, server: example.duckdns.org, request: "GET /websockify HTTP/1.1", host: "example.duckdns.org:8443"

j0nnymoe commented 2 months ago

Should work fine with subfolders, we provide a config for that too. Your error looks like it's having issues with web sockets.

LinuxServer-CI commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

recall704 commented 1 month ago

example i used

---
services:
  webtop:
    image: lscr.io/linuxserver/webtop:ubuntu-kde
    container_name: webtop
    security_opt:
      - seccomp:unconfined #optional
    environment:
      - TZ=Asia/Shanghai
      - SUBFOLDER=/abcd/ #optional
      - TITLE=VNC #optional
      - CUSTOM_PORT=8888
    volumes:
      - ./data:/config
      - /var/run/docker.sock:/var/run/docker.sock #optional
    ports:
      - 13000:8888
      - 13001:3001
    shm_size: "1gb" #optional
    restart: unless-stopped

nginx config file

# cat conf.d/abcd.conf 
map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
}

server {
    listen                  1080;
    server_name             localhost;

    location ^~ /abcd {
        #include /config/nginx/proxy.conf;
        #include /config/nginx/resolver.conf;
        set $upstream_app 10.10.10.10;
        set $upstream_port 13000;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

        proxy_buffering off;

    }
}

and then visit http://10.10.10.10:1080/abcd/