coder / code-server

VS Code in the browser
https://coder.com
MIT License
66.51k stars 5.45k forks source link

Syntax highlighting does not work behind Nginx. #6806

Closed matthew-st closed 1 month ago

matthew-st commented 1 month ago

Is there an existing issue for this?

OS/Web Information

Steps to Reproduce

  1. Put code-server behind nginx
  2. Access through nginx

Expected

Syntax highlighting should work the same as it does without Nginx.

Actual

Syntax highlighting is very basic when running behind Nginx, leaving most of the code white.

Logs

May 21 12:39:31 code-server[101786]: [12:39:31] [127.0.0.1][a403d907][ManagementConnection] New connection established.
May 21 12:39:32 code-server[101786]: [12:39:32] [127.0.0.1][bba0054d][ExtensionHostConnection] New connection established.
May 21 12:39:32 code-server[101786]: [12:39:32] [127.0.0.1][bba0054d][ExtensionHostConnection] <121530> Launched Extension Host Process.
May 21 12:40:22 code-server[101786]: [12:40:22] [192.168.1.79][3f7e8241][ManagementConnection] The client has disconnected gracefully, so the connection will be dispose>
May 21 12:40:22 code-server[101786]: [12:40:22] [192.168.1.79][a8ea5943][ExtensionHostConnection] <112217> Extension Host Process exited with code: 0, signal: null.
May 21 12:40:23 code-server[101786]: File not found: /usr/lib/code-server/lib/vscode/out/vsda_bg.wasm
May 21 12:40:23 code-server[101786]: File not found: /usr/lib/code-server/lib/vscode/out/vsda.js
May 21 12:40:23 code-server[101786]: [12:40:23] [192.168.1.79][ecb15821][ManagementConnection] New connection established.
May 21 12:40:24 code-server[101786]: [12:40:24] [192.168.1.79][1777e7cd][ExtensionHostConnection] New connection established.
May 21 12:40:24 code-server[101786]: [12:40:24] [192.168.1.79][1777e7cd][ExtensionHostConnection] <124589> Launched Extension Host Process.
May 21 12:43:54 code-server[101786]: [12:43:54] [127.0.0.1][a403d907][ManagementConnection] The client has disconnected gracefully, so the connection will be disposed.
May 21 12:43:54 code-server[101786]: [12:43:54] [127.0.0.1][bba0054d][ExtensionHostConnection] <121530> Extension Host Process exited with code: 0, signal: null.
May 21 12:43:55 code-server[101786]: File not found: /usr/lib/code-server/lib/vscode/out/vsda_bg.wasm
May 21 12:43:55 code-server[101786]: File not found: /usr/lib/code-server/lib/vscode/out/vsda.js

Screenshot/Video

Accessing through Nginx

Screenshot 2024-05-21 at 13 46 13

Accessing without Nginx

Screenshot 2024-05-21 at 13 46 31

Does this bug reproduce in native VS Code?

No, this works as expected in native VS Code

Does this bug reproduce in GitHub Codespaces?

I did not test GitHub Codespaces

Are you accessing code-server over a secure context?

Notes

When accessing without Nginx, I am accessing over an insecure context. Nginx is being used to add SSL to the connection.

code-asher commented 1 month ago

Does the problem happen in Safari only or any browser?

matthew-st commented 1 month ago

Does the problem happen in Safari only or any browser?

I tested it in Google Chrome, seems to happen there as well. 204

benz0li commented 1 month ago

@matthew-st It is recommended to access https/wss over port 443.

Can you please share your nginx configuration?

matthew-st commented 1 month ago

My nginx configuration is as seen below:

server {
    listen      8080 default_server ssl;
    server_name [domain name];
    ssl_certificate [cert location];
    ssl_certificate_key [cert key location];
    include     nginxconfig.io/security.conf;

    location / {
        proxy_pass http://127.0.0.1:8081;
        proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_connect_timeout      60;   
    proxy_send_timeout         90;   
    proxy_read_timeout         90; 
    proxy_buffer_size          4k; 
    proxy_buffers              4 32k;
    proxy_busy_buffers_size    64k;  
    proxy_temp_file_write_size 64k;
    }
    include nginxconfig.io/general.conf;
}

Sorry for the delay, got busy with stuff outside of this.

benz0li commented 1 month ago

This is may be related to one or both of the following point:

  1. You access securely, but over an IP
    • Although this is possible, some software refuses to work
  2. You access securely, but over 8080
    • 8080/tcp is a common alternative HTTP (not HTTPS) port

I have no idea what nginxconfig.io/general.conf and nginxconfig.io/security.conf include in addition.

benz0li commented 1 month ago

@matthew-st This has nothing to do with code-server, as my reference deployment at https://demo.jupyter.b-data.ch [which uses Traefik for TLS Termination][^1] works perfectly fine.

[^1]: Traefik: TLS termination, proxy no. 1; JupyterHub: proxy no. 2; JupyterLab (Jupyter Server Proxy): proxy no. 3; code-server: web app (proxy no. 4)

benz0li commented 1 month ago

@matthew-st This may be it: Your configuration is missing proxy_set_header X-Forwarded-Proto $scheme;

matthew-st commented 1 month ago

@matthew-st This has nothing to do with code-server, as my reference deployment at https://demo.jupyter.b-data.ch [which uses Traefik for TLS Termination]1 works perfectly fine.

Footnotes

  1. Traefik: TLS termination, proxy no. 1; JupyterHub: proxy no. 2; JupyterLab (Jupyter Server Proxy): proxy no. 3; code-server: web app (proxy no. 4)

Thought I'd ask just in case anyone knew.

@matthew-st This may be it: Your configuration is missing proxy_set_header X-Forwarded-Proto $scheme;

That seems to have fixed it for me, thank you.