Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to serve code-server through inverting proxy #142

Open
pkvprakash opened this issue Nov 4, 2024 · 0 comments
Open

Unable to serve code-server through inverting proxy #142

pkvprakash opened this issue Nov 4, 2024 · 0 comments

Comments

@pkvprakash
Copy link

pkvprakash commented Nov 4, 2024

Image

Problem description:

When I try to access code-server behind inverting proxy, I get the page loaded with websocket errors.

Dataproc Image : Ubuntu 20.04
Browser : MS Edge
Code server version : 4.91.0

Steps to reproduce:

  1. Create a dataproc custer, with component gateway enabled.
  2. Stop google-dataproc-component-gateway and knox services sudo systemctl stop knox google-dataproc-component-gateway
  3. Install code-server on the master node. Refer: https://coder.com/docs/code-server/install#debian-ubuntu
  4. Start code-server on port 8080, auth none for testing. code-server --verbose --auth none
  5. Start component gateway on console so that you can see the logs. user@codeserver-test-m:~$ /usr/bin/proxy-forwarding-agent -proxy https://us-central1.dataproc.cloud.google.com/tun/m/<a-hex-string>/ -host localhost:8080 -backend xxxxxxxxxx -session-cookie-name=_xsrf -shim-path websocket-shim
  6. Use dataproc url to access code server using browser. Eg: https://xxxxxxxxxxxxxxx-dot-us-central1.dataproc.googleusercontent.com and observe the logs

Outcome

On browser:

TRACE [remote-connection][Management   ][d2d47…][initial][WebSocket(xxxxxxxxxx-dot-us-central1.dataproc.googleusercontent.com:443)] 1/6. invoking socketFactory.connect().  log.ts:419  
INFO Creating a socket (renderer-Management-d2d47e5e-d55e-469d-aea3-9ccdd1b4091e)...  log.ts:419  
INFO Creating a socket (renderer-Management-d2d47e5e-d55e-469d-aea3-9ccdd1b4091e) was successful after 1568 ms.   log.ts:399 
TRACE [remote-connection][Management   ][d2d47…][initial][WebSocket(xxxxxxxxxx-dot-us-central1.dataproc.googleusercontent.com:443)] 2/6. socketFactory.connect() was successful.    log.ts:399 
TRACE [remote-connection][Management   ][d2d47…][initial][WebSocket(xxxxxxxxxx-dot-us-central1.dataproc.googleusercontent.com:443)] 3/6. sending AuthRequest control message.      log.ts:399 
TRACE [remote-connection][Management   ][d2d47…][initial][WebSocket(xxxxxxxxxx-dot-us-central1.dataproc.googleusercontent.com:443)] 4/6. received SignRequest control message.     log.ts:399 
TRACE [remote-connection][Management   ][d2d47…][initial][WebSocket(xxxxxxxxxx-dot-us-central1.dataproc.googleusercontent.com:443)] 5/6. sending ConnectionTypeRequest control message.  log.ts:439   
ERR [remote-connection][Management   ][d2d47…][initial][WebSocket(xxxxxxxxxx-dot-us-central1.dataproc.googleusercontent.com:443)] received error control message when negotiating connection. Error:    log.ts:439   
ERR Error: Connection error: Malformed second message
    at H (remoteAgentConnection.ts:783:17)
    at u.value (remoteAgentConnection.ts:326:17)
    at a.B (event.ts:1211:13)
    at a.fire (event.ts:1242:9)
    at n.fire (ipc.net.ts:650:19)
    at b.z (ipc.net.ts:1022:28)
    at u.value (ipc.net.ts:876:72)
    at a.B (event.ts:1211:13)
    at a.fire (event.ts:1242:9)
    at h.acceptChunk (ipc.net.ts:394:21)

On Console (code-server logs)

user@codeserver-test-m:~$ code-server --bind-addr 127.0.0.1:8080 --verbose --auth none
[2024-11-04T12:40:34.393Z] debug parent:10764 spawned child process 10782
[2024-11-04T12:40:34.758Z] debug child:10782 initiating handshake
[2024-11-04T12:40:34.762Z] debug parent:10764 got message {"message":{"type":"handshake"}}
[2024-11-04T12:40:34.764Z] debug child:10782 got message {"message":{"type":"handshake","args":{"bind-addr":"127.0.0.1:8080","auth":"none","password":"<redacted>","config":"/home/user/.config/code-server/config.yaml","verbose":true,"user-data-dir":"/home/user/.local/share/code-server","extensions-dir":"/home/user/.local/share/code-server/extensions","session-socket":"/home/user/.local/share/code-server/code-server-ipc.sock","log":"trace","host":"127.0.0.1","port":8080,"proxy-domain":[],"_":[],"usingEnvPassword":false,"usingEnvHashedPassword":false}}}
[2024-11-04T12:40:34.765Z] info  code-server 4.91.0 fb3e3e1546d571e9973e86482bcd925c1918ec27
[2024-11-04T12:40:34.765Z] info  Using user-data-dir /home/user/.local/share/code-server
[2024-11-04T12:40:34.765Z] debug Using extensions-dir /home/user/.local/share/code-server/extensions
[2024-11-04T12:40:34.787Z] info  Using config file /home/user/.config/code-server/config.yaml
[2024-11-04T12:40:34.787Z] info  HTTP server listening on http://127.0.0.1:8080/
[2024-11-04T12:40:34.787Z] info    - Authentication is disabled
[2024-11-04T12:40:34.787Z] info    - Not serving HTTPS
[2024-11-04T12:40:34.787Z] info  Session server listening on /home/user/.local/share/code-server/code-server-ipc.sock

....
….

[12:45:02] [127.0.0.1][6b8b0d5b] Malformed second message

...

Component gateway logs

user@codeserver-test-m:~$ /usr/bin/proxy-forwarding-agent             -proxy https://us-central1.dataproc.cloud.google.com/tun/m/<a-hex-string>/             -host localhost:8080             -backend xxxxxxxxxx                    -session-cookie-name=_xsrf -shim-path websocket-shim 
2024/11/04 13:47:42 Skipping metric handler initialization due to empty arguments.
2024/11/04 13:49:19 Websocket connection to the server "ws://localhost:8080/stable-090e0fad76152d6a0c10903a3bbf8a83d09e93d0?reconnectionToken=b5d11bcd-da5c-4e94-8b6a-8badae78dfe3&reconnection=false&skipWebSocketFrames=false" established for session: 1
2024/11/04 13:49:55 Websocket failure: failed to read a websocket message from the server: websocket: close 1006 (abnormal closure): unexpected EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant