Code-server: Blank page in proxy pass

Created on 22 Apr 2020  路  11Comments  路  Source: cdr/code-server

I have set up reverse proxy in apache for my local code-sever install.

Everything is okay till the login screen, but after that, I get nothing just blank screen. I checked the console log and its full of 200 errors.

Eg. I have set up code-server in local system with IP http://172.x.x.x:8000 and proxy-passed it to https://example.com/abc/test/code-server/

The command I used:
Screenshot (17)

Where am I doing wrong?

needs-investigation

Most helpful comment

I had the same issue with nginx when just using the basic proxy_pass option alone. Works with:

location / {
      proxy_pass http://localhost:8000;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_set_header Host $host;
  }

All 11 comments

then, in your browser, if you go to http://172.18.0.3:8000, don't you get vscode?

then, in your browser, if you go to http://172.18.0.3:8000, don't you get vscode?

Yes, I get vs code when I visit the local ip. But proxy-pass isn't working. I even tried with --auth none flag. I just get a blank page.

Console log:
Screenshot (18)

Proxy pass settings:
Screenshot (19)

apache-conf setting(found it somewhere in the issues):

Screenshot (20)

I'm under huge pressure of getting this work done. Please help.

Do you have the mod_proxy_wstunnel module enabled?

Oh you've got a base path. You might just need to include it in the rewrite. Here's a configuration I just tested which seems to work:

<VirtualHost *:8080>
  ServerName localhost

  RewriteEngine On
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /test/path/(.*) ws://localhost:8081/$1 [P,L]
  RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  RewriteRule /test/path/(.*) http://localhost:8081/$1 [P,L]
</VirtualHost>

I tried that. Not working. I am getting the same error. After debugging I found something.

debug got message from vs code {"message":{"type":"options","id":"baQ06AJ0CeQaBICxDzAGSvf8","options":{"workbenchWebConfiguration":{"remoteAuthority":"172.16.112.2","logLevel":0},"remoteUserDataUri":{"$mid":1,"path":"/root/.local/share/code-server","scheme":"vscode-remote","authority":"172.16.112.2"},"productConfiguration":{"nameShort":"Code - OSS","nameLong":"Code - OSS","applicationName":"code-oss","dataFolderName":".vscode-oss","win32MutexName":"vscodeoss","licenseName":"MIT","licenseUrl":"https://github.com/Microsoft/vscode/blob/master/LICENSE.txt","win32DirName":"Microsoft Code OSS","win32NameVersion":"Microsoft Code OSS","win32RegValueName":"CodeOSS","win32AppId":"{{E34003BB-9E10-4501-8C11-BE3FAA83F23F}","win32x64AppId":"{{D77B7E06-80BA-4137-BCF4-654B95CCEBC5}","win32UserAppId":"{{C6065F05-9603-4FC4-8101-B9781A25D88E}","win32x64UserAppId":"{{C6065F05-9603-4FC4-8101-B9781A25D88E}","win32AppUserModelId":"Microsoft.CodeOSS","win32ShellNameShort":"C&ode - OSS","darwinBundleIdentifier":"com.visualstudio.code.oss","linuxIconName":"com.visualstudio.code.oss","licenseFileName":"LICENSE.txt","reportIssueUrl":"https://github.com/cdr/code-server/issues/new","urlProtocol":"code-oss","extensionAllowedProposedApi":["ms-vscode.references-view"],"commit":"28e91ba70cd70fa9adf3f2e3e3b87631b5667ecf","date":"2020-04-14T22:51:57.043Z","version":"1.43.2","extensionsGallery":{"serviceUrl":"https://extensions.coder.com/api","itemUrl":"","controlUrl":"","recommendationsUrl":""}},"nlsConfiguration":{"locale":"en","availableLanguages":{}},"commit":"28e91ba70cd70fa9adf3f2e3e3b87631b5667ecf"}}}

This is the debug log. Here, it is looking for directories(/root/.local/share/code-server) in 172.16.112.2. But that is not the server in which it is installed. That is the main server to which it is proxy-passed.

How do i make it look into the directory in which it is installed? I guess that might be the error. Also there is some websocket error in console log.

The remote authority won't actually affect where it looks for the directory; all files and directories are only accessed on the local machine where code-server is running.

We always set the remote authority to the host header so that's just what your proxy is providing to code-server. I think the only thing it's used for is setting cookies but it won't be used if it's an IP address so in your case it shouldn't have any effect.

Were you able to confirm whether you have the mod_proxy_wstunnel module enabled? So far that's the only other way I've been able to replicate the issue.

I also have this issue using a base-path behind a traefik proxy. It worked fine prior to v3.1. The web debugger is full of errors due code-server looking for dependencies at the root path; ignoring the base-path prefix.

For Traefik this might help: https://github.com/cdr/code-server/issues/1608#issuecomment-627109454

I had the same issue with nginx when just using the basic proxy_pass option alone. Works with:

location / {
      proxy_pass http://localhost:8000;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_set_header Host $host;
  }

I had the same issue with nginx when just using the basic proxy_pass option alone. Works with:

location / {
      proxy_pass http://localhost:8000;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_set_header Host $host;
  }

Did you try doing that for a sub directory?

It's unlikely this is a bug with code-server.

Can you try to follow our setup guide with caddy and see if you can get it working?

See https://github.com/cdr/code-server/blob/master/doc/guide.md

If not I'll reopen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pchecinski picture pchecinski  路  3Comments

oonqt picture oonqt  路  3Comments

infogulch picture infogulch  路  3Comments

lshamis picture lshamis  路  3Comments

avelino picture avelino  路  3Comments