2019-07-23 20:38:00 +00:00
|
|
|
# Quickstart Guide
|
|
|
|
1. Visit the [releases page](https://github.com/cdr/code-server/releases) and
|
|
|
|
download the latest binary for your operating system.
|
|
|
|
2. Unpack the downloaded file then run the binary.
|
2019-08-08 16:21:45 +00:00
|
|
|
3. In your browser navigate to `localhost:8080`.
|
2019-07-23 20:38:00 +00:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
Run `code-server --help` to view available options.
|
|
|
|
|
|
|
|
### Encrypting traffic with HTTPS
|
|
|
|
To encrypt the traffic between the browser and server use `code-server --cert`
|
|
|
|
followed by the path to your certificate. Additionally, you can use certificate
|
|
|
|
keys with `--cert-key` followed by the path to your key. If you pass `--cert`
|
|
|
|
without any path code-server will generate a self-signed certificate.
|
|
|
|
|
|
|
|
You can use [Let's Encrypt](https://letsencrypt.org/) to get an SSL certificate
|
|
|
|
for free.
|
|
|
|
|
|
|
|
### Nginx Reverse Proxy
|
|
|
|
The trailing slashes are important.
|
|
|
|
|
|
|
|
```
|
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
listen [::]:80;
|
|
|
|
server_name code.example.com code.example.org;
|
|
|
|
location /some/path/ { # Or / if hosting at the root.
|
2019-08-08 16:21:45 +00:00
|
|
|
proxy_pass http://localhost:8080/;
|
2019-07-23 20:38:00 +00:00
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection upgrade;
|
|
|
|
proxy_set_header Accept-Encoding gzip;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Apache Reverse Proxy
|
|
|
|
```
|
|
|
|
<VirtualHost *:80>
|
|
|
|
ServerName code.example.com
|
|
|
|
|
|
|
|
RewriteEngine On
|
|
|
|
RewriteCond %{HTTP:Upgrade} =websocket [NC]
|
2019-08-08 16:21:45 +00:00
|
|
|
RewriteRule /(.*) ws://localhost:8080/$1 [P,L]
|
2019-07-23 20:38:00 +00:00
|
|
|
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
|
2019-08-08 16:21:45 +00:00
|
|
|
RewriteRule /(.*) http://localhost:8080/$1 [P,L]
|
2019-07-23 20:38:00 +00:00
|
|
|
|
|
|
|
ProxyRequests off
|
2019-09-16 19:18:58 +00:00
|
|
|
ProxyPass / http://localhost:8080/ nocanon
|
2019-08-08 16:21:45 +00:00
|
|
|
ProxyPassReverse / http://localhost:8080/
|
2019-07-23 20:38:00 +00:00
|
|
|
</VirtualHost>
|
|
|
|
```
|
2019-09-16 20:05:25 +00:00
|
|
|
|
|
|
|
### Run automatically at startup
|
|
|
|
|
|
|
|
In some cases you might need to run code-server automatically once the host starts. You may use your local init service to do so.
|
|
|
|
|
|
|
|
#### Systemd
|
|
|
|
|
|
|
|
```ini
|
|
|
|
[Unit]
|
2019-09-30 16:19:46 +00:00
|
|
|
Description=Code Server IDE
|
2019-09-16 20:05:25 +00:00
|
|
|
After=network.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=simple
|
2019-09-30 16:19:46 +00:00
|
|
|
User=<USER>
|
|
|
|
EnvironmentFile=$HOME/.profile
|
|
|
|
WorkingDirectory=$HOME
|
2019-09-16 20:05:25 +00:00
|
|
|
Restart=on-failure
|
2019-09-30 16:19:46 +00:00
|
|
|
RestartSec=10
|
2019-09-16 20:05:25 +00:00
|
|
|
|
2019-09-30 16:19:46 +00:00
|
|
|
ExecStart=<PATH TO BINARY> $(pwd)
|
2019-09-16 20:05:25 +00:00
|
|
|
|
2019-09-30 16:19:46 +00:00
|
|
|
StandardOutput=file:/var/log/code-server-output.log
|
|
|
|
StandardError=file:/var/log/code-server-error.log
|
2019-09-16 20:05:25 +00:00
|
|
|
|
2019-09-30 16:19:46 +00:00
|
|
|
[Install]
|
2019-09-16 20:05:25 +00:00
|
|
|
WantedBy=multi-user.target
|
|
|
|
```
|
|
|
|
|
|
|
|
#### OpenRC
|
|
|
|
|
|
|
|
```sh
|
|
|
|
#!/sbin/openrc-run
|
|
|
|
|
|
|
|
depend() {
|
|
|
|
after net-online
|
|
|
|
need net
|
|
|
|
}
|
|
|
|
|
|
|
|
supervisor=supervise-daemon
|
|
|
|
name="code-server"
|
|
|
|
command="/opt/cdr/code-server"
|
|
|
|
command_args=""
|
|
|
|
|
|
|
|
pidfile="/var/run/cdr.pid"
|
|
|
|
respawn_delay=5
|
|
|
|
|
|
|
|
set -o allexport
|
|
|
|
if [ -f /etc/environment ]; then source /etc/environment; fi
|
|
|
|
set +o allexport
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Kubernetes/Docker
|
|
|
|
|
|
|
|
Make sure you set your restart policy to always - this will ensure your container starts as the daemon starts.
|