|
1 | 1 | # Getting Started
|
2 | 2 |
|
3 |
| -[code-server](https://coder.com) is used by developers at Azure, Google, Reddit, and more to give them access to VS Code in the browser. |
| 3 | +[code-server](https://coder.com) is used by developers at Azure, Google, |
| 4 | +Reddit, and more to give them access to VS Code in the browser. |
4 | 5 |
|
5 | 6 | ## Quickstart Guide
|
6 | 7 |
|
7 |
| -> 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). |
| 8 | +> 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), |
| 9 | +> [tweet (@coderhq)](https://twitter.com/coderhq) or |
| 10 | +> [email](mailto:[email protected]?subject=Self-hosted%20quickstart%20guide). |
8 | 11 |
|
9 |
| -This document pertains to Coder specific implementations of VS Code. For documentation on how to use VS Code itself, please refer to the official [documentation for VS Code](https://code.visualstudio.com/docs) |
| 12 | +This document pertains to Coder-specific implementations of VS Code. For |
| 13 | +documentation on how to use VS Code itself, please refer to the official |
| 14 | +[documentation for VS Code](https://code.visualstudio.com/docs) |
10 | 15 |
|
11 |
| -It takes just a few minutes to get your own self-hosted server running. If you've got a machine running macOS, Windows, or Linux, you're ready to start the binary which listens on port `8443` by default. |
| 16 | +It takes just a few minutes to get your own self-hosted server running. If |
| 17 | +you've got a machine running macOS, Windows, or Linux, you're ready to start |
| 18 | +the binary which listens on ports `8443` and `8444` by default. |
12 | 19 |
|
13 | 20 | <!--
|
14 | 21 | DO NOT CHANGE THIS TO A CODEBLOCK.
|
15 | 22 | We want line breaks for readability, but backslashes to escape them do not work cross-platform.
|
16 | 23 | This uses line breaks that are rendered but not copy-pasted to the clipboard.
|
17 | 24 | -->
|
18 | 25 |
|
| 26 | +1. Visit [the releases](https://github.com/cdr/code-server/releases) page and |
| 27 | + download the latest cli for your operating system. |
| 28 | +2. Double click the executable to run in the current directory. |
| 29 | +3. Copy the password that appears in the CLI. <img src="../assets/cli.png"> |
| 30 | +4. In your browser navigate to `localhost:8443`. |
| 31 | +5. Paste the password from the cli into the login window. <img src="../assets/server-password-modal.png"> |
19 | 32 |
|
20 |
| -1. Visit [the releases](https://github.com/cdr/code-server/releases) page and download the latest cli for your operating system |
21 |
| -2. Double click the executable to run in the current directory |
22 |
| -3. Copy the password that appears in the cli<img src="../assets/cli.png"> |
23 |
| -4. In your browser navigate to `localhost:8443` |
24 |
| -5. Paste the password from the cli into the login window<img src="../assets/server-password-modal.png"> |
25 |
| -> NOTE: Be careful with your password as sharing it will grant those users access to your server's file system |
| 33 | +> NOTE: Be careful with your password as sharing it will grant those users |
| 34 | +> access to your server's file system |
26 | 35 |
|
27 | 36 | ### Things To Know
|
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"> |
| 37 | +- When you visit the IP for your code-server instance, you will be greeted with |
| 38 | + a page similar to the following screenshot. Code-server is using a |
| 39 | + self-signed SSL certificate for easy setup. In Chrome/Chromium, click |
| 40 | + **"Advanced"** then click **"proceed anyway"**. In Firefox, click |
| 41 | + **Advanced**, then **Add Exception**, then finally **Confirm Security |
| 42 | + Exception**. <img src ="../assets/chrome_warning.png"> |
29 | 43 |
|
30 | 44 | ## Usage
|
31 |
| -<pre class="pre-wrap"><code>code-server<span class="virtual-br"></span> --help</code></pre> |
| 45 | +``` |
| 46 | +code-server --help |
| 47 | +``` |
| 48 | + |
| 49 | +code-server can be ran with a number of arguments to customize your working |
| 50 | +directory, host, port, and SSL certificate. |
| 51 | + |
| 52 | +### Data Directory |
| 53 | +Use `code-server --user-data-dir path/to/directory` to specify the root folder |
| 54 | +that VS Code will start in. |
| 55 | + |
| 56 | +### Host |
| 57 | +By default, code-server will use `127.0.0.1` for insecure connections and |
| 58 | +`0.0.0.0` for secure connections. This can be changed by using |
| 59 | +`code-server --host `. |
| 60 | + |
| 61 | +> Example: `code-server --host 127.0.0.1` |
| 62 | +
|
| 63 | +### Open |
| 64 | +You can have the server automatically open the VS Code in your browser on |
| 65 | +startup by using the `code-server -o` or `code-server --open` flags |
| 66 | + |
| 67 | +### Port |
| 68 | +By default, code-server will use `8443` as its port. This can be changed by |
| 69 | +using `code-server -p` or `code-server --port=` followed by the port you want |
| 70 | +to use. |
| 71 | + |
| 72 | +> Example: `code-server -p 9000` |
| 73 | +
|
| 74 | +### Cert and Cert Key |
| 75 | +To encrypt the traffic between the browser and server use `code-server --cert` |
| 76 | +followed by the path to your `.cer` file. Additionally, you can use certificate |
| 77 | +keys with `code-server --cert-key` followed by the path to your `.key` file. |
32 | 78 |
|
33 |
| -code-server can be ran with a number of arguments to customize your working directory, host, port, and SSL certificate. |
| 79 | +Example: |
| 80 | +``` |
| 81 | +code-server --cert /path/to/certificate/fullchain.cer --cert-key /path/to/certificate/fullchain.key |
| 82 | +``` |
34 | 83 |
|
| 84 | +Example for Let's Encrypt: |
35 | 85 | ```
|
36 |
| -Usage: code-server [options] |
37 |
| -
|
38 |
| -Run VS Code on a remote server. |
39 |
| -
|
40 |
| -Options: |
41 |
| - -V, --version output the version number |
42 |
| - --cert <value> |
43 |
| - --cert-key <value> |
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 |
| 86 | +code-server --cert /etc/letsencrypt/live/example.com/fullchain.pem --cert-key /etc/letsencrypt/live/example.com/privkey.key |
58 | 87 | ```
|
59 | 88 |
|
60 |
| - ### Data Directory |
61 |
| - 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. |
62 |
| - |
63 |
| - ### Host |
64 |
| - By default, code-server will use `0.0.0.0` as its address. This can be changed by using `code-server -h` or `code-server --host=` followed by the address you want to use. |
65 |
| - > Example: `code-server -h 127.0.0.1` |
66 |
| -
|
67 |
| - ### Open |
68 |
| - You can have the server automatically open the VS Code in your browser on startup by using the `code-server -o` or `code-server --open` flags |
69 |
| - |
70 |
| - ### Port |
71 |
| - By default, code-server will use `8443` as its port. This can be changed by using `code-server -p` or `code-server --port=` followed by the port you want to use. |
72 |
| - > Example: `code-server -p 9000` |
73 |
| -
|
74 |
| - ### Telemetry |
75 |
| - Disable all telemetry with `code-server --disable-telemetry`. |
76 |
| - |
77 |
| - ### Cert and Cert Key |
78 |
| - To encrypt the traffic between the browser and server use `code-server --cert=` followed by the path to your `.cer` file. Additionally, you can use certificate keys with `code-server --cert-key` followed by the path to your `.key` file. |
79 |
| -> Example (certificate and key): `code-server --cert /etc/letsencrypt/live/example.com/fullchain.cer --cert-key /etc/letsencrypt/live/example.com/fullchain.key` |
80 |
| -> Example (if you are using Letsencrypt or similar): `code-server --cert /etc/letsencrypt/live/example.com/fullchain.pem --cert-key /etc/letsencrypt/live/example.com/privkey.key` |
81 |
| -
|
82 |
| -> To ensure the connection between you and your server is encrypted view our guide on [securing your setup](../security/ssl.md) |
83 |
| -
|
84 |
| - ### Nginx Reverse Proxy |
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. |
86 |
| - ``` |
87 |
| - server { |
88 |
| - listen 80; |
89 |
| - listen [::]:80; |
90 |
| - server_name code.example.com code.example.org; |
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 |
| - } |
| 89 | +To ensure the connection between you and your server is encrypted view our |
| 90 | +guide on [securing your setup](../security/ssl.md). |
| 91 | + |
| 92 | +### Nginx Reverse Proxy |
| 93 | +Below is a virtual host example that works with code-server. Please also pass |
| 94 | +`--allow-http` and `--trust-proxy` to code-server to allow the proxy to |
| 95 | +connect. You can also use Let's Encrypt to get a SSL certificates for free. |
| 96 | + |
| 97 | +``` |
| 98 | +server { |
| 99 | + listen 80; |
| 100 | + listen [::]:80; |
| 101 | + server_name code.example.com code.example.org; |
| 102 | + location / { |
| 103 | + proxy_pass http://localhost:8443/; |
| 104 | + proxy_set_header Upgrade $http_upgrade; |
| 105 | + proxy_set_header Connection upgrade; |
| 106 | + proxy_set_header Accept-Encoding gzip; |
97 | 107 | }
|
98 |
| - ``` |
| 108 | +} |
| 109 | +``` |
| 110 | + |
| 111 | +### Apache Reverse Proxy |
| 112 | +Example of an HTTPS virtualhost configuration for Apache as a reverse proxy. |
| 113 | +Please also pass `--allow-http` and `--trust-proxy` to code-server to allow the |
| 114 | +proxy to connect. You can also use Let's Encrypt to get a SSL certificates for |
| 115 | +free. |
99 | 116 |
|
100 |
| - ### Apache Reverse Proxy |
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. |
102 |
| - ``` |
103 |
| - <VirtualHost *:80> |
104 |
| - ServerName code.example.com |
| 117 | +``` |
| 118 | +<VirtualHost *:80> |
| 119 | + ServerName code.example.com |
105 | 120 |
|
106 |
| - RewriteEngine On |
107 |
| - RewriteCond %{HTTP:Upgrade} =websocket [NC] |
108 |
| - RewriteRule /(.*) ws://localhost:8443/$1 [P,L] |
109 |
| - RewriteCond %{HTTP:Upgrade} !=websocket [NC] |
110 |
| - RewriteRule /(.*) http://localhost:8443/$1 [P,L] |
| 121 | + RewriteEngine On |
| 122 | + RewriteCond %{HTTP:Upgrade} =websocket [NC] |
| 123 | + RewriteRule /(.*) ws://localhost:8443/$1 [P,L] |
| 124 | + RewriteCond %{HTTP:Upgrade} !=websocket [NC] |
| 125 | + RewriteRule /(.*) http://localhost:8443/$1 [P,L] |
111 | 126 |
|
112 |
| - ProxyRequests off |
| 127 | + ProxyRequests off |
113 | 128 |
|
114 |
| - RequestHeader set X-Forwarded-Proto https |
115 |
| - RequestHeader set X-Forwarded-Port 443 |
| 129 | + RequestHeader set X-Forwarded-Proto https |
| 130 | + RequestHeader set X-Forwarded-Port 443 |
116 | 131 |
|
117 |
| - ProxyPass / http://localhost:8443/ nocanon |
118 |
| - ProxyPassReverse / http://localhost:8443/ |
| 132 | + ProxyPass / http://localhost:8443/ nocanon |
| 133 | + ProxyPassReverse / http://localhost:8443/ |
| 134 | +
|
| 135 | +</VirtualHost> |
| 136 | +``` |
| 137 | +*Important:* For more details about Apache reverse proxy configuration checkout |
| 138 | +the [documentation](https://httpd.apache.org/docs/current/mod/mod_proxy.html) - |
| 139 | +especially the [Securing your Server](https://httpd.apache.org/docs/current/mod/mod_proxy.html#access) |
| 140 | +section. |
119 | 141 |
|
120 |
| - </VirtualHost> |
121 |
| - ``` |
122 |
| - *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 |
123 | 142 |
|
124 |
| - ### Help |
125 |
| - Use `code-server --help` to view the usage for the CLI. This is also shown at the beginning of this section. |
| 143 | +### Help |
| 144 | +Use `code-server --help` to view the usage for the CLI. |
0 commit comments