Skip to content

Black Screen When Using Nginx #333

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

Closed
vedantroy opened this issue Mar 24, 2019 · 7 comments
Closed

Black Screen When Using Nginx #333

vedantroy opened this issue Mar 24, 2019 · 7 comments
Labels
bug Something isn't working

Comments

@vedantroy
Copy link

  • code-server version: 1.32.0
  • OS Version: Ubuntu 18 LTS (aws t2.micro)

Description

I am self hosting code server. When I first tried to run code-server, I ran into this error: #121. I fixed the error by specifying -d /home/[user]/.code-server and manually creating /home/[user]/.code-server/Backups/workspaces.json as a blank file.

However, while code server allows me to log in, I get a grey screen and the following error prints to the console:

ERROR SHARED stderr {"data":"Uncaught Exception: Error: Unexpected end of JSON input\n\nSyntaxError: Unexpected end of JSON input\n at JSON.parse (<anonymous>)\n at pfs_1.readFile.then.contents (eval at exports.requireModule (/home/ubuntu/code-server-1.32.0-310-linux-x64/code-server:468:27684), <anonymous>:77277:45)\n at <anonymous>\n at Timeout.setTimeout [as _onTimeout] (eval at exports.requireModule (/home/ubuntu/code-server-1.32.0-310-linux-x64/code-server:468:27684), <anonymous>:52540:31)\n at ontimeout (timers.js:498:11)\n at tryOnTimeout (timers.js:323:5)\n at Timer.listOnTimeout (timers.js:290:5)\n"}

I am using the following command:
code-server --allow-http -p 3001 -d .code-server/ my-project-dir
I am using allow-http because I am using nginx as a reverse proxy.

Steps to Reproduce

  1. Use binary installation of code server.
  2. Create blank /home/[user]/.code-server/Backups/workspaces.json file
  3. Run code-server -p <some port> -d .code-server/
  4. Log in
  5. You should see a blank grey screen and an error should be printed to the console.
@vedantroy vedantroy added the bug Something isn't working label Mar 24, 2019
@nol166
Copy link
Contributor

nol166 commented Mar 25, 2019

@vedantroy I followed your steps but was able to load the IDE. I did, however, see the Unexpected end of JSON error in the console. I am running MacOS however.

@vedantroy
Copy link
Author

vedantroy commented Mar 25, 2019

Maybe there is a template workspaces.json file I can use, so I don't run into this parsing error?

I opened developer tools to get more information on the error. I saw this:

Screenshot_Of_Code_Server

Loading IDE
Starting Socket [1/5]...
WebSocket connection to wss://dev.confs.app failed: Error during WebSocket handshake: Unexpected response code: 200

The actual IDE screen looked like this:

Screenshot_Of_Server

@nol166
Copy link
Contributor

nol166 commented Mar 25, 2019

Are you using nginx by chance?

@vedantroy
Copy link
Author

vedantroy commented Mar 25, 2019

Yes. My original post in this thread says I am using nginx as a reverse proxy.
Update: I fixed the issue using this websockets/ws#979 thread.

@vedantroy
Copy link
Author

I fixed the issue with the following thread: websockets/ws#979

In Nginx, you need to set the following headers:

location / {
    proxy_pass http://foobar:3005/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
}

@vedantroy vedantroy changed the title Black Screen - Unexpected end of JSON input when parsing workspaces.json Black Screen When Using Nginx Mar 25, 2019
@boardfish
Copy link

Still getting this despite the fix. Symptoms resemble #469.

@boardfish
Copy link

Not getting this any more on CentOS 7 behind jwilder/nginx-proxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants