| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,6 +65,35 @@ only to HTTP requests. | |||
| 65 | 65 | You can use [Let's Encrypt](https://letsencrypt.org/) to get an SSL certificate | |
| 66 | 66 | for free. | |
| 67 | 67 | ||
| 68 | + ## How do I securely access web services? | ||
| 69 | + | ||
| 70 | + code-server is capable of proxying to any port using either a subdomain or a | ||
| 71 | + subpath which means you can securely access these services using code-server's | ||
| 72 | + built-in authentication. | ||
| 73 | + | ||
| 74 | + ### Sub-domains | ||
| 75 | + | ||
| 76 | + You will need a DNS entry that points to your server for each port you want to | ||
| 77 | + access. You can either set up a wildcard DNS entry for `*.<domain>` if your domain | ||
| 78 | + name registrar supports it or you can create one for every port you want to | ||
| 79 | + access (`3000.<domain>`, `8080.<domain>`, etc). | ||
| 80 | + | ||
| 81 | + You should also set up TLS certificates for these subdomains, either using a | ||
| 82 | + wildcard certificate for `*.<domain>` or individual certificates for each port. | ||
| 83 | + | ||
| 84 | + Start code-server with the `--proxy-domain` flag set to your domain. | ||
| 85 | + | ||
| 86 | + ``` | ||
| 87 | + code-server --proxy-domain <domain> | ||
| 88 | + ``` | ||
| 89 | + | ||
| 90 | + Now you can browse to `<port>.<domain>`. Note that this uses the host header so | ||
| 91 | + ensure your reverse proxy forwards that information if you are using one. | ||
| 92 | + | ||
| 93 | + ### Sub-paths | ||
| 94 | + | ||
| 95 | + Just browse to `/proxy/<port>/`. | ||
| 96 | + | ||
| 68 | 97 | ## x86 releases? | |
| 69 | 98 | ||
| 70 | 99 | node has dropped support for x86 and so we decided to as well. See | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,7 @@ | |||
| 17 | 17 | "devDependencies": { | |
| 18 | 18 | "@types/adm-zip": "^0.4.32", | |
| 19 | 19 | "@types/fs-extra": "^8.0.1", | |
| 20 | + "@types/http-proxy": "^1.17.4", | ||
| 20 | 21 | "@types/mocha": "^5.2.7", | |
| 21 | 22 | "@types/node": "^12.12.7", | |
| 22 | 23 | "@types/parcel-bundler": "^1.12.1", | |
@@ -52,13 +53,14 @@ | |||
| 52 | 53 | "@coder/logger": "1.1.11", | |
| 53 | 54 | "adm-zip": "^0.4.14", | |
| 54 | 55 | "fs-extra": "^8.1.0", | |
| 56 | + "http-proxy": "^1.18.0", | ||
| 55 | 57 | "httpolyglot": "^0.1.2", | |
| 56 | 58 | "node-pty": "^0.9.0", | |
| 57 | 59 | "pem": "^1.14.2", | |
| 58 | 60 | "safe-compare": "^1.1.4", | |
| 59 | 61 | "semver": "^7.1.3", | |
| 60 | - "tar": "^6.0.1", | ||
| 61 | 62 | "ssh2": "^0.8.7", | |
| 63 | + "tar": "^6.0.1", | ||
| 62 | 64 | "tar-fs": "^2.0.0", | |
| 63 | 65 | "ws": "^7.2.0" | |
| 64 | 66 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ | |||
| 17 | 17 | href="{{BASE}}/static/{{COMMIT}}/src/browser/media/manifest.json" | |
| 18 | 18 | crossorigin="use-credentials" | |
| 19 | 19 | /> | |
| 20 | - <link rel="apple-touch-icon" href="{{BASE}}/static/{{COMMIT}}/src/browser/media/pwa-icon-384.pnggg" /> | ||
| 20 | + <link rel="apple-touch-icon" href="{{BASE}}/static/{{COMMIT}}/src/browser/media/pwa-icon-384.png" /> | ||
| 21 | 21 | <link href="{{BASE}}/static/{{COMMIT}}/dist/pages/app.css" rel="stylesheet" /> | |
| 22 | 22 | <meta id="coder-options" data-settings="{{OPTIONS}}" /> | |
| 23 | 23 | </head> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,7 +43,7 @@ export class ApiHttpProvider extends HttpProvider { | |||
| 43 | 43 | ||
| 44 | 44 | public async handleRequest(route: Route, request: http.IncomingMessage): Promise<HttpResponse> { | |
| 45 | 45 | this.ensureAuthenticated(request) | |
| 46 | - if (route.requestPath !== "/index.html") { | ||
| 46 | + if (!this.isRoot(route)) { | ||
| 47 | 47 | throw new HttpError("Not found", HttpCode.NotFound) | |
| 48 | 48 | } | |
| 49 | 49 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,7 @@ export class DashboardHttpProvider extends HttpProvider { | |||
| 20 | 20 | } | |
| 21 | 21 | ||
| 22 | 22 | public async handleRequest(route: Route, request: http.IncomingMessage): Promise<HttpResponse> { | |
| 23 | - if (route.requestPath !== "/index.html") { | ||
| 23 | + if (!this.isRoot(route)) { | ||
| 24 | 24 | throw new HttpError("Not found", HttpCode.NotFound) | |
| 25 | 25 | } | |
| 26 | 26 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ interface LoginPayload { | |||
| 18 | 18 | */ | |
| 19 | 19 | export class LoginHttpProvider extends HttpProvider { | |
| 20 | 20 | public async handleRequest(route: Route, request: http.IncomingMessage): Promise<HttpResponse> { | |
| 21 | - if (this.options.auth !== AuthType.Password || route.requestPath !== "/index.html") { | ||
| 21 | + if (this.options.auth !== AuthType.Password || !this.isRoot(route)) { | ||
| 22 | 22 | throw new HttpError("Not found", HttpCode.NotFound) | |
| 23 | 23 | } | |
| 24 | 24 | switch (route.base) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,43 @@ | |||
| 1 | + import * as http from "http" | ||
| 2 | + import { HttpCode, HttpError } from "../../common/http" | ||
| 3 | + import { HttpProvider, HttpResponse, Route, WsResponse } from "../http" | ||
| 4 | + | ||
| 5 | + /** | ||
| 6 | + * Proxy HTTP provider. | ||
| 7 | + */ | ||
| 8 | + export class ProxyHttpProvider extends HttpProvider { | ||
| 9 | + public async handleRequest(route: Route, request: http.IncomingMessage): Promise<HttpResponse> { | ||
| 10 | + if (!this.authenticated(request)) { | ||
| 11 | + if (this.isRoot(route)) { | ||
| 12 | + return { redirect: "/login", query: { to: route.fullPath } } | ||
| 13 | + } | ||
| 14 | + throw new HttpError("Unauthorized", HttpCode.Unauthorized) | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + // Ensure there is a trailing slash so relative paths work correctly. | ||
| 18 | + if (this.isRoot(route) && !route.fullPath.endsWith("/")) { | ||
| 19 | + return { | ||
| 20 | + redirect: `${route.fullPath}/`, | ||
| 21 | + } | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + const port = route.base.replace(/^\//, "") | ||
| 25 | + return { | ||
| 26 | + proxy: { | ||
| 27 | + base: `${this.options.base}/${port}`, | ||
| 28 | + port, | ||
| 29 | + }, | ||
| 30 | + } | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public async handleWebSocket(route: Route, request: http.IncomingMessage): Promise<WsResponse> { | ||
| 34 | + this.ensureAuthenticated(request) | ||
| 35 | + const port = route.base.replace(/^\//, "") | ||
| 36 | + return { | ||
| 37 | + proxy: { | ||
| 38 | + base: `${this.options.base}/${port}`, | ||
| 39 | + port, | ||
| 40 | + }, | ||
| 41 | + } | ||
| 42 | + } | ||
| 43 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,7 +61,7 @@ export class UpdateHttpProvider extends HttpProvider { | |||
| 61 | 61 | this.ensureAuthenticated(request) | |
| 62 | 62 | this.ensureMethod(request) | |
| 63 | 63 | ||
| 64 | - if (route.requestPath !== "/index.html") { | ||
| 64 | + if (!this.isRoot(route)) { | ||
| 65 | 65 | throw new HttpError("Not found", HttpCode.NotFound) | |
| 66 | 66 | } | |
| 67 | 67 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,7 +126,7 @@ export class VscodeHttpProvider extends HttpProvider { | |||
| 126 | 126 | ||
| 127 | 127 | switch (route.base) { | |
| 128 | 128 | case "/": | |
| 129 | - if (route.requestPath !== "/index.html") { | ||
| 129 | + if (!this.isRoot(route)) { | ||
| 130 | 130 | throw new HttpError("Not found", HttpCode.NotFound) | |
| 131 | 131 | } else if (!this.authenticated(request)) { | |
| 132 | 132 | return { redirect: "/login", query: { to: this.options.base } } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,6 +39,7 @@ export interface Args extends VsArgs { | |||
| 39 | 39 | readonly "install-extension"?: string[] | |
| 40 | 40 | readonly "show-versions"?: boolean | |
| 41 | 41 | readonly "uninstall-extension"?: string[] | |
| 42 | + readonly "proxy-domain"?: string[] | ||
| 42 | 43 | readonly locale?: string | |
| 43 | 44 | readonly _: string[] | |
| 44 | 45 | } | |
@@ -111,6 +112,7 @@ const options: Options<Required<Args>> = { | |||
| 111 | 112 | "install-extension": { type: "string[]", description: "Install or update a VS Code extension by id or vsix." }, | |
| 112 | 113 | "uninstall-extension": { type: "string[]", description: "Uninstall a VS Code extension by id." }, | |
| 113 | 114 | "show-versions": { type: "boolean", description: "Show VS Code extension versions." }, | |
| 115 | + "proxy-domain": { type: "string[]", description: "Domain used for proxying ports." }, | ||
| 114 | 116 | ||
| 115 | 117 | locale: { type: "string" }, | |
| 116 | 118 | log: { type: LogLevel }, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments