question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to run code-server behind cloudflare and nginx

See original GitHub issue

I can’t find any documentation on how to run code-server behind an https url without using ssl on code-server.

I can’t figure out for the life of me how to have code-server answering to a certain https domain with the ssl certification handled by another system. Probably I’m not experienced enough and there is a very simple way to achieve this, but I fail no matter what I try. (is there a code-server documentation effort somewhere?)

Here is my scenario:

  • I want to run code-server on c.begiter.net.
  • I have code-server installed (not docker) on my server.
  • begiter.net DNS, and HTTPS is managed by CloudFlare.
  • I have nginx installed on my server, with multiple sub-domains registered. None of them employ ssl since that part is handled by CloudFlare.
  • c.begiter.net is proxied to localhost:9999, which runs code-server.

If I access with IP (and self-signed certificate - https://IP:9999), everything works fine on the desktop. On my iPad, after the password screen, websocket upgrades fail with 1006. I tried with Safari, Firefox, Chrome, Yandex, and Aloha browsers. I got Chrome to dump errors to Javascript console and the gist of it is http upgrade fails with code 1006 (which apparently is a browser-related error code, not something you can fix on the server).

Accessing with c.begiter.net fails with a white screen of death, with nginx reporting “upstream error”. Meaning, code-server on localhost:9999 does not respond to requests - my guess, since they are to https://c.begiter.net but CloudFlare sends http:// requests to my server.

I can’t figure out what command line parameters to use for code-server. Here is my current command line: /home/necmettin/editor/code-server --port 9999 --user-data-dir /home/necmettin/editor/user-data --extensions-dir /home/necmettin/editor/extension-data --auth password --disable-ssh --host 213.159.29.172 --cert /home/necmettin/editor/cert/editor.crt --cert-key /home/necmettin/editor/cert/editor.key

And here is my nginx proxy setup (for Location / or c.begiter.net):

proxy_pass http://unix:/tmp/editor.sock;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Accept-Encoding gzip;
proxy_set_header Host $host;

What am I doing wrong? What is the correct way to do this? Please advise.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:30 (11 by maintainers)

github_iconTop GitHub Comments

6reactions
nhooyrcommented, Apr 28, 2020

You cannot proxy to localhost:9999. localhost is only accessible locally, you need to make code-server listen on your servers public IP and proxy Cloudflare to that.

5reactions
cmoogcommented, Oct 13, 2020

We’re making it easier to access your code-server instance securely from any device. We’ve eliminated the need for configuring TLS, domain registration, DNS, DoS protect, and authentication. To gain pre-release access, please consider joining our alpha program.

cc @necmettin @TomaruDev @HPaulson

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to run code-server behind cloudflare and nginx #1560
I have code-server installed (not docker) on my server. begiter.net DNS, and HTTPS is managed by CloudFlare. I have nginx installed on my...
Read more >
Self Hosted Code Server secured by Cloudflare Tunnel
In this tutorial I will show you how can you use Cloudflare ... you would usually set up with some reverse-proxy software like...
Read more >
How To Host a Website Using Cloudflare and Nginx on ...
First, make sure that UFW will allow HTTPS traffic. Enable Nginx Full , which will open both port 80 (HTTP) and port 443...
Read more >
How to install Vs code with Argo tunnel - Cloudflare Community
How to set up and use code-server. ... I want use SSL. So should I directly connect to port 8080 or use nginx...
Read more >
Usage - code-server v4.8.0 docs - Coder
How to set up and use code-server. ... Port forwarding via SSH; Using Let's Encrypt with Caddy; Using Let's Encrypt with NGINX; Using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found