Skip to content

doc/guide: Improve nginx docs #1902

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

Merged
merged 2 commits into from
Jul 22, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 45 additions & 23 deletions doc/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [SSH forwarding](#ssh-forwarding)
- [Let's Encrypt](#lets-encrypt)
- [Self Signed Certificate](#self-signed-certificate)
- [NGINX](#nginx)
- [Change the password?](#change-the-password)
- [How do I securely access development web services?](#how-do-i-securely-access-development-web-services)

Expand Down Expand Up @@ -193,6 +194,8 @@ mydomain.com
reverse_proxy 127.0.0.1:8080
```

Remember to replace `mydomain.com` with your domain name!

5. Reload caddy with:

```bash
Expand All @@ -204,6 +207,48 @@ Visit `https://<your-domain-name>` to access `code-server`. Congratulations!
In a future release we plan to integrate Let's Encrypt directly with `code-server` to avoid
the dependency on caddy.

#### NGINX

If you prefer to use NGINX instead of Caddy then please follow steps 1-2 above and then:

3. Install `nginx`:

```bash
sudo apt update
sudo apt install -y nginx certbot python-certbot-nginx
```

4. Put the following config into `/etc/nginx/sites-available/code-server` with sudo:

```nginx
server {
listen 80;
listen [::]:80;
server_name mydomain.com;

location / {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
}
}
```

Remember to replace `mydomain.com` with your domain name!

5. Enable the config:

```bash
sudo ln -s ../sites-available/code-server /etc/nginx/sites-enabled/code-server
sudo certbot --non-interactive --redirect --agree-tos --nginx -d mydomain.com -m [email protected]
```

Make sure to substiute `[email protected]` with your actual email.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo on substitute.


Visit `https://<your-domain-name>` to access `code-server`. Congratulations!

### Self Signed Certificate

**note:** Self signed certificates do not work with iPad and will cause a blank page. You'll
Expand Down Expand Up @@ -244,29 +289,6 @@ To avoid the warnings, you can use [mkcert](https://mkcert.dev) to create a self
trusted by your OS and then pass it into `code-server` via the `cert` and `cert-key` config
fields.

### Nginx reverse proxy

If you prefer to use Nginx instead of Caddy here is a sample config (put e.g. in
`/etc/nginx/sites-enabled/code-server`):

```nginx
server {
listen 80 [::]:80;
server_name your-domain-name-here.com;

location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
}
}
```

It's highly recommended to set up a LetsEncrypt certificate and HTTP->HTTPS redirect as well.
In order to do this run `certbot --nginx -d your-domain-name-here.com`.

### Change the password?

Edit the `password` field in the `code-server` config file at `~/.config/code-server/config.yaml`
Expand Down