Skip to content

Commit 1293bb4

Browse files
committed
Merge branch 'master' of github.com:cdr/code-server
2 parents 4ab1bd9 + f25a614 commit 1293bb4

File tree

28 files changed

+319
-142
lines changed

28 files changed

+319
-142
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ before_deploy:
2727
- git config --local user.name "$USER_NAME"
2828
- git config --local user.email "$USER_EMAIL"
2929
- git tag "$VERSION" "$TRAVIS_COMMIT"
30-
- if [[ “$TRAVIS_OS_NAME” == “osx” ]]; then yarn task package $VERSION; fi
3130
deploy:
3231
provider: releases
3332
file_glob: true

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ How to [secure your setup](/doc/security/ssl.md).
5555
### Known Issues
5656
5757
- Creating custom VS Code extensions and debugging them doesn't work.
58+
- To debug Golang using [ms-vscode-go extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go), you need to add `--security-opt seccomp=unconfined` to your `docker run` arguments when launching code-server with Docker. See [#725](https://github.com/cdr/code-server/issues/725) for details.
5859
5960
### Future
6061
- **Stay up to date!** Get notified about new releases of code-server.

build/tasks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const buildServerBinary = register("build:server:binary", async (runner) => {
2121
logger.info("Building with environment", field("env", {
2222
NODE_ENV: process.env.NODE_ENV,
2323
VERSION: process.env.VERSION,
24+
OSTYPE: process.env.OSTYPE,
25+
TARGET: process.env.TARGET,
2426
}));
2527

2628
await ensureInstalled();

doc/admin/install/aws.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ If you're just starting out, we recommend [installing code-server locally](../..
1111
### Use the AWS wizard
1212

1313
- Click **Launch Instance** from your [EC2 dashboard](https://console.aws.amazon.com/ec2/v2/home).
14-
- Select the Ubuntu Server 16.04 LTS (HVM), SSD Volume Type (`ami-0f9cf087c1f27d9b1)` at this time of writing)
14+
- Select the Ubuntu Server 18.04 LTS (HVM), SSD Volume Type
1515
- Select an appropriate instance size (we recommend t2.medium/large, depending on team size and number of repositories/languages enabled), then **Next: Configure Instance Details**
16-
- Select **Next: ...** until you get to the **Configure Security Group** page, then add the default **HTTP** rule (port range "80", source "0.0.0.0/0, ::/0")
16+
- Select **Next: ...** until you get to the **Configure Security Group** page, then add a **Custom TCP Rule** rule with port range set to `8443` and source set to "Anywhere"
1717
> Rules with source of 0.0.0.0/0 allow all IP addresses to access your instance. We recommend setting [security group rules](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html?icmpid=docs_ec2_console) to allow access from known IP addresses only.
1818
- Click **Launch**
1919
- You will be prompted to create a key pair
@@ -39,15 +39,15 @@ If you're just starting out, we recommend [installing code-server locally](../..
3939
```
4040
- Replace {version} in the following command with the version found on the releases page and run it (or just copy the download URL from the releases page):
4141
```
42-
wget https://github.com/cdr/code-server/releases/download/{version}/code-server-{version}-linux-x64.tar.gz
42+
wget https://github.com/cdr/code-server/releases/download/{version}/code-server{version}-linux-x64.tar.gz
4343
```
4444
- Extract the downloaded tar.gz file with this command, for example:
4545
```
46-
tar -xvzf code-server-{version}-linux-x64.tar.gz
46+
tar -xvzf code-server{version}-linux-x64.tar.gz
4747
```
4848
- Navigate to extracted directory with this command:
4949
```
50-
cd code-server-{version}-linux-x64
50+
cd code-server{version}-linux-x64
5151
```
5252
- If you run into any permission errors, make the binary executable by running:
5353
```
@@ -56,14 +56,11 @@ If you're just starting out, we recommend [installing code-server locally](../..
5656
> To ensure the connection between you and your server is encrypted view our guide on [securing your setup](../../security/ssl.md)
5757
- Finally, run
5858
```
59-
sudo ./code-server -p 80
59+
./code-server
6060
```
61-
- When you visit the public IP for your AWS instance, you will be greeted with this page. Code-server is using a self-signed SSL certificate for easy setup. To proceed to the IDE, click **"Advanced"**<img src ="../../assets/chrome_warning.png">
62-
- Then click **"proceed anyway"**<img src="../../assets/chrome_confirm.png">
61+
- Open your browser and visit `https://$public_ip:8443/` (where `$public_ip` is your AWS instance's public IP address). You will be greeted with a page similar to the following screenshot. Code-server is using a self-signed SSL certificate for easy setup. In Chrome/Chromium, click **"Advanced"** then click **"proceed anyway"**. In Firefox, click **Advanced**, then **Add Exception**, then finally **Confirm Security Exception**.<img src ="../../assets/chrome_warning.png">
6362

6463
> For instructions on how to keep the server running after you end your SSH session please checkout [how to use systemd](https://www.linode.com/docs/quick-answers/linux/start-service-at-boot/) to start linux based services if they are killed
6564
66-
> The `-p 80` flag is necessary in order to make the IDE accessible from the public IP of your instance (also available from the description in the instances page.
67-
6865
---
6966
> NOTE: If you get stuck or need help, [file an issue](https://github.com/cdr/code-server/issues/new?&title=Improve+self-hosted+quickstart+guide), [tweet (@coderhq)](https://twitter.com/coderhq) or [email](mailto:[email protected]?subject=Self-hosted%20quickstart%20guide).

doc/admin/install/digitalocean.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ If you're just starting out, we recommend [installing code-server locally](../..
2222
```
2323
- Replace {version} in the following command with the version found on the releases page and run it (or just copy the download URL from the releases page):
2424
```
25-
wget https://github.com/cdr/code-server/releases/download/{version}/code-server-{version}-linux-x64.tar.gz
25+
wget https://github.com/cdr/code-server/releases/download/{version}/code-server{version}-linux-x64.tar.gz
2626
```
2727
- Extract the downloaded tar.gz file with this command, for example:
2828
```
29-
tar -xvzf code-server-{version}-linux-x64.tar.gz
29+
tar -xvzf code-server{version}-linux-x64.tar.gz
3030
```
3131
- Navigate to extracted directory with this command:
3232
```
33-
cd code-server-{version}-linux-x64
33+
cd code-server{version}-linux-x64
3434
```
3535
- If you run into any permission errors when attempting to run the binary:
3636
```
@@ -39,11 +39,10 @@ If you're just starting out, we recommend [installing code-server locally](../..
3939
> To ensure the connection between you and your server is encrypted view our guide on [securing your setup](../../security/ssl.md)
4040
- Finally start the code-server
4141
```
42-
sudo ./code-server -p 80
42+
./code-server
4343
```
4444
> For instructions on how to keep the server running after you end your SSH session please checkout [how to use systemd](https://www.linode.com/docs/quick-answers/linux/start-service-at-boot/) to start linux based services if they are killed
45-
- When you visit the public IP for your Digital Ocean instance, you will be greeted with this page. Code-server is using a self-signed SSL certificate for easy setup. To proceed to the IDE, click **"Advanced"**<img src ="../../assets/chrome_warning.png">
46-
- Then click **"proceed anyway"**<img src="../../assets/chrome_confirm.png">
45+
- Open your browser and visit `https://$public_ip:8443/` (where `$public_ip` is your Digital Ocean instance's public IP address). You will be greeted with a page similar to the following screenshot. Code-server is using a self-signed SSL certificate for easy setup. In Chrome/Chromium, click **"Advanced"** then click **"proceed anyway"**. In Firefox, click **Advanced**, then **Add Exception**, then finally **Confirm Security Exception**.<img src ="../../assets/chrome_warning.png">
4746

4847
---
4948
> NOTE: If you get stuck or need help, [file an issue](https://github.com/cdr/code-server/issues/new?&title=Improve+self-hosted+quickstart+guide), [tweet (@coderhq)](https://twitter.com/coderhq) or [email](mailto:[email protected]?subject=Self-hosted%20quickstart%20guide).

doc/admin/install/google_cloud.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ If you're just starting out, we recommend [installing code-server locally](../..
1212
- [Open your Google Cloud console](https://console.cloud.google.com/compute/instances) to create a new VM instance and click **Create Instance**
1313
- Choose an appropriate machine type (we recommend 2 vCPU and 7.5 GB RAM, more depending on team size and number of repositories/languages enabled)
1414
- Choose Ubuntu 16.04 LTS as your boot disk
15-
- Check the boxes for **Allow HTTP traffic** and **Allow HTTPS traffic** in the **Firewall** section
15+
- Expand the "Management, security, disks, networking, sole tenancy" section, go to the "Networking" tab, then under network tags add "code-server"
1616
- Create your VM, and **take note** of its public IP address.
17+
- Visit "VPC network" in the console and go to "Firewall rules". Create a new firewall rule called "http-8443". Under "Target tags" add "code-server", and under "Protocols and ports" tick "Specified protocols and ports" and "tcp". Beside "tcp", add "8443", then create the rule.
1718
- Copy the link to download the latest Linux binary from our [releases page](https://github.com/cdr/code-server/releases)
1819

1920
---
@@ -32,40 +33,34 @@ https://github.com/cdr/code-server/releases/latest
3233

3334
- Replace {version} in the following command with the version found on the releases page and run it (or just copy the download URL from the releases page):
3435
```
35-
wget https://github.com/cdr/code-server/releases/download/{version}/code-server-{version}-linux-x64.tar.gz
36+
wget https://github.com/cdr/code-server/releases/download/{version}/code-server{version}-linux-x64.tar.gz
3637
```
3738

3839
- Extract the downloaded tar.gz file with this command, for example:
3940
```
40-
tar -xvzf code-server-{version}-linux-x64.tar.gz
41+
tar -xvzf code-server{version}-linux-x64.tar.gz
4142
```
4243

4344
- Navigate to extracted directory with this command:
4445
```
45-
cd code-server-{version}-linux-x64
46+
cd code-server{version}-linux-x64
4647
```
4748

4849
- Make the binary executable if you run into any errors regarding permission:
4950
```
5051
chmod +x code-server
5152
```
5253

53-
> To ensure the connection between you and your server is encrypted view our guide on [securing your setup](../security/ssl.md)
54+
> To ensure the connection between you and your server is encrypted view our guide on [securing your setup](../../security/ssl.md)
5455
5556
- Start the code-server
56-
```
57-
sudo ./code-server -p 80
58-
```
57+
```
58+
./code-server
59+
```
60+
- Open your browser and visit `https://$public_ip:8443/` (where `$public_ip` is your Compute Engine instance's public IP address). You will be greeted with a page similar to the following screenshot. Code-server is using a self-signed SSL certificate for easy setup. In Chrome/Chromium, click **"Advanced"** then click **"proceed anyway"**. In Firefox, click **Advanced**, then **Add Exception**, then finally **Confirm Security Exception**.<img src ="../../assets/chrome_warning.png">
5961

6062
> For instructions on how to keep the server running after you end your SSH session please checkout [how to use systemd](https://www.linode.com/docs/quick-answers/linux/start-service-at-boot/) to start linux based services if they are killed
6163
62-
- Access code-server from the public IP of your Google Cloud instance we noted earlier in your browser.
63-
> example: 32.32.32.234
64-
65-
- You will be greeted with this page. Code-server is using a self-signed SSL certificate for easy setup. To proceed to the IDE, click **"Advanced"**<img src ="../../assets/chrome_warning.png">
66-
67-
- Then click **"proceed anyway"**<img src="../../assets/chrome_confirm.png">
68-
6964
---
7065

7166
> NOTE: If you get stuck or need help, [file an issue](https://github.com/cdr/code-server/issues/new?&title=Improve+self-hosted+quickstart+guide), [tweet (@coderhq)](https://twitter.com/coderhq) or [email](mailto:[email protected]?subject=Self-hosted%20quickstart%20guide).

doc/assets/chrome_confirm.png

-19 KB
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Fail2Ban filter for code-server
2+
#
3+
#
4+
5+
[Definition]
6+
7+
8+
failregex = ^INFO\s+Failed login attempt\s+{\"password\":\"(\\.|[^"])*\",\"remote_address\":\"<HOST>\"
9+
10+
ignoreregex =
11+
12+
datepattern = "timestamp":{EPOCH}}$
13+
14+
# Author: Dean Sheather
15+

doc/security/fail2ban.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Protecting code-server from bruteforce attempts
2+
3+
code-server outputs all failed login attempts, along with the IP address,
4+
provided password, user agent and timestamp by default. When using a reverse
5+
proxy such as Nginx or Apache, the remote address may appear to be `127.0.0.1`
6+
or a similar address unless the `--trust-proxy` argument is provided to
7+
code-server.
8+
9+
When used with the `--trust-proxy` argument, code-server will use the last IP in
10+
`X-Forwarded-For` (if provided) instead of the remote socket address. Ensure
11+
that you are setting this value in your reverse proxy:
12+
13+
Nginx:
14+
```
15+
location / {
16+
...
17+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
18+
...
19+
}
20+
```
21+
22+
Apache:
23+
```
24+
<VirtualEnv>
25+
...
26+
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
27+
...
28+
</VirtualEnv>
29+
```
30+
31+
It is extremely important that if you enable `--trust-proxy` you ensure your
32+
code-server instance is not accessible from the internet (block it in your
33+
firewall).
34+
35+
## Fail2Ban
36+
37+
Fail2Ban allows for automatically banning and logging repeated failed
38+
authentication attempts for many applications through regex filters. A working
39+
filter for code-server can be found in `./code-server.fail2ban.conf`. Once this
40+
is installed and configured correctly, repeated failed login attempts should
41+
automatically be banned from connecting to your server.
42+

doc/self-hosted/index.md

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ It takes just a few minutes to get your own self-hosted server running. If you'v
2525
> NOTE: Be careful with your password as sharing it will grant those users access to your server's file system
2626
2727
### Things To Know
28-
- When you visit the IP for your code-server, you will be greeted with this page. Code-server is using a self-signed SSL certificate for easy setup. To proceed to the IDE, click **"Advanced"**<img src ="../assets/chrome_warning.png">
29-
- Then click **"proceed anyway"**<img src="../assets/chrome_confirm.png">
28+
- When you visit the IP for your code-server instance, you will be greeted with a page similar to the following screenshot. Code-server is using a self-signed SSL certificate for easy setup. In Chrome/Chromium, click **"Advanced"** then click **"proceed anyway"**. In Firefox, click **Advanced**, then **Add Exception**, then finally **Confirm Security Exception**.<img src ="../assets/chrome_warning.png">
3029

3130
## Usage
3231
<pre class="pre-wrap"><code>code-server<span class="virtual-br"></span> --help</code></pre>
@@ -39,21 +38,24 @@ Usage: code-server [options]
3938
Run VS Code on a remote server.
4039
4140
Options:
42-
-V, --version output the version number
41+
-V, --version output the version number
4342
--cert <value>
4443
--cert-key <value>
45-
-e, --extensions-dir <dir> Set the root path for extensions.
46-
-d --user-data-dir <dir> Specifies the directory that user data is kept in, useful when running as root.
47-
--data-dir <value> DEPRECATED: Use '--user-data-dir' instead. Customize where user-data is stored.
48-
-h, --host <value> Customize the hostname. (default: "0.0.0.0")
49-
-o, --open Open in the browser on startup.
50-
-p, --port <number> Port to bind on. (default: 8443)
51-
-N, --no-auth Start without requiring authentication.
52-
-H, --allow-http Allow http connections.
53-
-P, --password <value> Specify a password for authentication.
54-
--disable-telemetry Disables ALL telemetry.
55-
--help output usage information
56-
```
44+
-e, --extensions-dir <dir> Override the main default path for user extensions.
45+
--extra-extensions-dir [dir] Path to an extra user extension directory (repeatable). (default: [])
46+
--extra-builtin-extensions-dir [dir] Path to an extra built-in extension directory (repeatable). (default: [])
47+
-d, --user-data-dir <dir> Specifies the directory that user data is kept in, useful when running as root.
48+
-h, --host <value> Customize the hostname. (default: "0.0.0.0")
49+
-o, --open Open in the browser on startup.
50+
-p, --port <number> Port to bind on. (default: 8443)
51+
-N, --no-auth Start without requiring authentication.
52+
-H, --allow-http Allow http connections.
53+
--disable-telemetry Disables ALL telemetry.
54+
--socket <value> Listen on a UNIX socket. Host and port will be ignored when set.
55+
--trust-proxy Trust the X-Forwarded-For header, useful when using a reverse proxy.
56+
--install-extension <value> Install an extension by its ID.
57+
-h, --help output usage information
58+
```
5759

5860
### Data Directory
5961
Use `code-server -d (path/to/directory)` or `code-server --user-data-dir=(path/to/directory)`, excluding the parentheses to specify the root folder that VS Code will start in.
@@ -80,23 +82,23 @@ Options:
8082
> To ensure the connection between you and your server is encrypted view our guide on [securing your setup](../security/ssl.md)
8183
8284
### Nginx Reverse Proxy
83-
Nginx is for reverse proxy. Below is a virtual host example that works with code-server. Please also pass --allow-http. You can also use certbot by EFF to get a ssl certificates for free.
85+
Below is a virtual host example that works with code-server. Please also pass `--allow-http` and `--trust-proxy` to code-server to allow the proxy to connect. You can also use Let's Encrypt to get a SSL certificates for free.
8486
```
8587
server {
8688
listen 80;
8789
listen [::]:80;
8890
server_name code.example.com code.example.org;
89-
location / {
90-
proxy_pass http://localhost:8443/;
91-
proxy_set_header Upgrade $http_upgrade;
92-
proxy_set_header Connection upgrade;
93-
proxy_set_header Accept-Encoding gzip;
94-
}
95-
}
91+
location / {
92+
proxy_pass http://localhost:8443/;
93+
proxy_set_header Upgrade $http_upgrade;
94+
proxy_set_header Connection upgrade;
95+
proxy_set_header Accept-Encoding gzip;
96+
}
97+
}
9698
```
97-
99+
98100
### Apache Reverse Proxy
99-
Example of https virtualhost configuration for Apache as a reverse proxy. Please also pass --allow-http on code-server startup to allow the proxy to connect.
101+
Example of a HTTPS virtualhost configuration for Apache as a reverse proxy. Please also pass `--allow-http` and `--trust-proxy` to code-server to allow the proxy to connect. You can also use Let's Encrypt to get a SSL certificates for free.
100102
```
101103
<VirtualHost *:80>
102104
ServerName code.example.com
@@ -106,7 +108,7 @@ Options:
106108
RewriteRule /(.*) ws://localhost:8443/$1 [P,L]
107109
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
108110
RewriteRule /(.*) http://localhost:8443/$1 [P,L]
109-
111+
110112
ProxyRequests off
111113
112114
RequestHeader set X-Forwarded-Proto https
@@ -118,6 +120,6 @@ Options:
118120
</VirtualHost>
119121
```
120122
*Important:* For more details about Apache reverse proxy configuration checkout the [documentation](https://httpd.apache.org/docs/current/mod/mod_proxy.html) - especially the [Securing your Server](https://httpd.apache.org/docs/current/mod/mod_proxy.html#access) section
121-
123+
122124
### Help
123125
Use `code-server --help` to view the usage for the CLI. This is also shown at the beginning of this section.

0 commit comments

Comments
 (0)