From 985212d91f8f730ba1c19224f172b3faa25b7e04 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 19 Jan 2023 10:11:07 -0700 Subject: [PATCH 1/6] docs: add port-forwarding --- docs/guide.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/guide.md b/docs/guide.md index fee3f8b64937..b9574ae818d0 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -5,6 +5,7 @@ - [Expose code-server](#expose-code-server) - [Port forwarding via SSH](#port-forwarding-via-ssh) + - [Port forwarding via code-server's built-in proxy](#port-forwarding-via-code-servers-built-in-proxy) - [Using Let's Encrypt with Caddy](#using-lets-encrypt-with-caddy) - [Using Let's Encrypt with NGINX](#using-lets-encrypt-with-nginx) - [Using a self-signed certificate](#using-a-self-signed-certificate) @@ -112,6 +113,18 @@ we recommend using another method, such as [Let's Encrypt](#let-encrypt) instead > [GPG agent](https://wiki.gnupg.org/AgentForwarding) to the instance to > securely access GitHub and sign commits without having to copy your keys. +### Port forwarding via code-server's built-in proxy + +code-server has a proxy built-in for port-forwarding. By default, ports running +on the same machine as code-server can be accessed at +{current_url}/proxy/{port}. For instance, if you have code-server running on +localhost:8080 and a Python server running on localhost:8000, you could access +it via http://localhost:8080/proxy/8000 + +You can also override the URL scheme for the proxy using the `VSCODE_PROXY_URI` +environment variable. `VSCODE_PROXY_URI=https://{{port}}.kyle.dev` would forward +an application running on localhost:3000 to https://3000.kyle.dev + ### Using Let's Encrypt with Caddy Using [Let's Encrypt](https://letsencrypt.org) is an option if you want to From a637e753dbfbfac1e1f45879dfd7fc4fe6443030 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 19 Jan 2023 15:50:50 -0700 Subject: [PATCH 2/6] fixup: formatting --- docs/guide.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/guide.md b/docs/guide.md index b9574ae818d0..bf7bc591966e 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -115,16 +115,6 @@ we recommend using another method, such as [Let's Encrypt](#let-encrypt) instead ### Port forwarding via code-server's built-in proxy -code-server has a proxy built-in for port-forwarding. By default, ports running -on the same machine as code-server can be accessed at -{current_url}/proxy/{port}. For instance, if you have code-server running on -localhost:8080 and a Python server running on localhost:8000, you could access -it via http://localhost:8080/proxy/8000 - -You can also override the URL scheme for the proxy using the `VSCODE_PROXY_URI` -environment variable. `VSCODE_PROXY_URI=https://{{port}}.kyle.dev` would forward -an application running on localhost:3000 to https://3000.kyle.dev - ### Using Let's Encrypt with Caddy Using [Let's Encrypt](https://letsencrypt.org) is an option if you want to @@ -313,6 +303,15 @@ If you're working on web services and want to access them locally, code-server can proxy to any port using either a subdomain or a subpath, allowing you to securely access these services using code-server's built-in authentication. +By default, ports running on the same machine as code-server can be accessed at +{current_url}/proxy/{port}. For instance, if you have code-server running on +localhost:8080 and a Python server running on localhost:8000, you could access +it via http://localhost:8080/proxy/8000 + +You can also override the URL scheme for the proxy using the `VSCODE_PROXY_URI` +environment variable. `VSCODE_PROXY_URI=https://{{port}}.kyle.dev` would forward +an application running on localhost:3000 to https://3000.kyle.dev + ### Using a subdomain You will need a DNS entry that points to your server for each port you want to From b2e683cc55e926b6ff13105bdda842c4fa1680c4 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 20 Jan 2023 11:05:51 -0700 Subject: [PATCH 3/6] Update docs/guide.md Co-authored-by: Asher --- docs/guide.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/guide.md b/docs/guide.md index bf7bc591966e..82f02d4b58eb 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -113,8 +113,6 @@ we recommend using another method, such as [Let's Encrypt](#let-encrypt) instead > [GPG agent](https://wiki.gnupg.org/AgentForwarding) to the instance to > securely access GitHub and sign commits without having to copy your keys. -### Port forwarding via code-server's built-in proxy - ### Using Let's Encrypt with Caddy Using [Let's Encrypt](https://letsencrypt.org) is an option if you want to From 077ad34fcfe78fb75b2416c69e604aa9ec413d97 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 20 Jan 2023 15:32:55 -0700 Subject: [PATCH 4/6] docs: clean up based on feedback --- docs/guide.md | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/docs/guide.md b/docs/guide.md index 82f02d4b58eb..e44784738a78 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -5,7 +5,6 @@ - [Expose code-server](#expose-code-server) - [Port forwarding via SSH](#port-forwarding-via-ssh) - - [Port forwarding via code-server's built-in proxy](#port-forwarding-via-code-servers-built-in-proxy) - [Using Let's Encrypt with Caddy](#using-lets-encrypt-with-caddy) - [Using Let's Encrypt with NGINX](#using-lets-encrypt-with-nginx) - [Using a self-signed certificate](#using-a-self-signed-certificate) @@ -15,6 +14,7 @@ - [Accessing web services](#accessing-web-services) - [Using a subdomain](#using-a-subdomain) - [Using a subpath](#using-a-subpath) + - [Using your own proxy](#using-your-own-proxy) - [Stripping `/proxy/` from the request path](#stripping-proxyport-from-the-request-path) - [Proxying to create a React app](#proxying-to-create-a-react-app) - [Proxying to a Vue app](#proxying-to-a-vue-app) @@ -306,10 +306,6 @@ By default, ports running on the same machine as code-server can be accessed at localhost:8080 and a Python server running on localhost:8000, you could access it via http://localhost:8080/proxy/8000 -You can also override the URL scheme for the proxy using the `VSCODE_PROXY_URI` -environment variable. `VSCODE_PROXY_URI=https://{{port}}.kyle.dev` would forward -an application running on localhost:3000 to https://3000.kyle.dev - ### Using a subdomain You will need a DNS entry that points to your server for each port you want to @@ -326,12 +322,29 @@ To set your domain, start code-server with the `--proxy-domain` flag: code-server --proxy-domain ``` -Now you can browse to `.`. Note that this uses the host header, so +For instance, if you have code-server exposed on `domain.tld` and a Python +server running on port 8080 of the same machine code-server is running on, you +could run code-server with `--proxy-domain domain.tld` and access the Python +server via `8080.domain.tld`. + +Note that this uses the host header, so ensure your reverse proxy (if you're using one) forwards that information. ### Using a subpath -Simply browse to `/proxy//`. +Simply browse to `/proxy//`. For instance, if you have code-server +exposed on `domain.tld` and a Python server running on port 8080 of the same +machine code-server is running on, you could access the Python server via +`domain.tld/proxy/8000`. + +### Using your own proxy + +You can make extensions and the ports panel use your own proxy by setting +`VSCODE_PROXY_URI`. For example if you set +`VSCODE_PROXY_URI=https://{{port}}.kyle.dev` when an application is detected +running on port 3000 of the same machine code-server is running on the ports +panel will create a link to https://3000.kyle.dev instead of pointing to the +built-in subpath-based proxy. ### Stripping `/proxy/` from the request path From c10d0cbb1564e477f18338fc9a17139b37fa9095 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Mon, 23 Jan 2023 09:07:19 -0700 Subject: [PATCH 5/6] docs: add relative paths paragraph --- docs/guide.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/guide.md b/docs/guide.md index e44784738a78..5aa6f3f30aea 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -346,6 +346,9 @@ running on port 3000 of the same machine code-server is running on the ports panel will create a link to https://3000.kyle.dev instead of pointing to the built-in subpath-based proxy. +Note: relative paths are also supported i.e. +`VSCODE_PROXY_URI=./proxy/{{port}}` + ### Stripping `/proxy/` from the request path You may notice that the code-server proxy strips `/proxy/` from the From cdb2934d14a45bd42175ae0281bfc684d09a6448 Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 27 Jan 2023 07:23:31 -0900 Subject: [PATCH 6/6] Remove dupe paragraph and fill paragraph --- docs/guide.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/guide.md b/docs/guide.md index 5aa6f3f30aea..019c619bd668 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -301,11 +301,6 @@ If you're working on web services and want to access them locally, code-server can proxy to any port using either a subdomain or a subpath, allowing you to securely access these services using code-server's built-in authentication. -By default, ports running on the same machine as code-server can be accessed at -{current_url}/proxy/{port}. For instance, if you have code-server running on -localhost:8080 and a Python server running on localhost:8000, you could access -it via http://localhost:8080/proxy/8000 - ### Using a subdomain You will need a DNS entry that points to your server for each port you want to @@ -327,8 +322,8 @@ server running on port 8080 of the same machine code-server is running on, you could run code-server with `--proxy-domain domain.tld` and access the Python server via `8080.domain.tld`. -Note that this uses the host header, so -ensure your reverse proxy (if you're using one) forwards that information. +Note that this uses the host header, so ensure your reverse proxy (if you're +using one) forwards that information. ### Using a subpath