From 02437824b386a10d18284c0cb7149cf372c4fdc9 Mon Sep 17 00:00:00 2001 From: "r.bideau" <7304827+rbideau@users.noreply.github.com> Date: Wed, 24 Feb 2021 18:36:20 +0100 Subject: [PATCH 1/5] Allow url.hostname in WebpackDevServer config Signed-off-by: r.bideau <7304827+rbideau@users.noreply.github.com> --- packages/cli/src/lib/bundler/server.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/cli/src/lib/bundler/server.ts b/packages/cli/src/lib/bundler/server.ts index 34284ead18..5fc3a7b5de 100644 --- a/packages/cli/src/lib/bundler/server.ts +++ b/packages/cli/src/lib/bundler/server.ts @@ -58,6 +58,8 @@ export async function serveBundle(options: ServeOptions) { host, port, proxy: pkg.proxy, + // When the dev server is behind a proxy, the host and public hostname differ + allowedHosts: [url.hostname], }); await new Promise((resolve, reject) => { From c9971cc040572aac0afcd44a7734c129a98adcbe Mon Sep 17 00:00:00 2001 From: "r.bideau" <7304827+rbideau@users.noreply.github.com> Date: Wed, 24 Feb 2021 18:37:03 +0100 Subject: [PATCH 2/5] Update contrib doc for proxy with configuration sample --- .../help-im-behind-a-corporate-proxy.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md b/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md index f5288cf144..71f14059e6 100644 --- a/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md +++ b/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md @@ -4,6 +4,8 @@ Let's admit it, we've all been there. Sometimes you've gotta run stuff with no w Whilst this isn't supported natively by Backstage, this might help you get your installation up and running making calls through the said proxy tunnel. +## backend + Unfortunately, `nodejs` does not respect `HTTP(S)_PROXY` environment variables by default, and the library that we use to provide `fetch` functionality `node-fetch` (provided by `cross-fetch`) does not also respect these environment variables. There are however some ways to get this to work without too much effort. It's most likely that you're going to run into these issues from the `backend` part of `backstage` as that's the part that isn't helped by your browser or OS's settings for the corporate proxy. @@ -56,3 +58,29 @@ if (process.env.HTTPS_PROXY) { ``` 4. Start the backend with `yarn start` + +## config + +If your development environnement is in the cloud (like with [AWS Cloud9](https://aws.amazon.com/cloud9/) or an instance of [Theia](https://theia-ide.org/)), you will need to update your configuration. + +In `app.local.config`, you will probably need to make some changes, the exact values will depend of your setup. + +For instance, if your public url is `https://your-public-url.com` and the port `3000` and `8080` are proxified as is: + +```yaml +app: + baseUrl: https://your-public-url.com:3000 + listen: + host: 0.0.0.0 # This make the dev server bind to localhost and not the baseUrl hostname + +backend: + baseUrl: https://your-public-url.com:8080 + listen: + port: 8080 + cors: + origin: https://your-public-url.com:3000 +``` + +If the protocole is `http`, you will need to set `backend.csp.upgrade-insecure-requests` to `false` as well. + +The app port must proxy websocket connection in order to have hot reloading. From 7aae53a2277fdc06a0618e5227474b5091ae95c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bideau?= <7304827+rbideau@users.noreply.github.com> Date: Wed, 24 Feb 2021 19:09:29 +0100 Subject: [PATCH 3/5] Fix typo contrib doc for proxy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adam Harvey Co-authored-by: Fredrik Adelöw --- .../docs/tutorials/help-im-behind-a-corporate-proxy.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md b/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md index 71f14059e6..de8a99e35d 100644 --- a/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md +++ b/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md @@ -61,9 +61,9 @@ if (process.env.HTTPS_PROXY) { ## config -If your development environnement is in the cloud (like with [AWS Cloud9](https://aws.amazon.com/cloud9/) or an instance of [Theia](https://theia-ide.org/)), you will need to update your configuration. +If your development environment is in the cloud (like with [AWS Cloud9](https://aws.amazon.com/cloud9/) or an instance of [Theia](https://theia-ide.org/)), you will need to update your configuration. -In `app.local.config`, you will probably need to make some changes, the exact values will depend of your setup. +In `app-config.local.yaml`, you will probably need to make some changes, the exact values will depend on your setup. For instance, if your public url is `https://your-public-url.com` and the port `3000` and `8080` are proxified as is: @@ -71,7 +71,7 @@ For instance, if your public url is `https://your-public-url.com` and the port ` app: baseUrl: https://your-public-url.com:3000 listen: - host: 0.0.0.0 # This make the dev server bind to localhost and not the baseUrl hostname + host: 0.0.0.0 # This makes the dev server bind to all IPv4 interfaces and not just the baseUrl hostname backend: baseUrl: https://your-public-url.com:8080 @@ -81,6 +81,6 @@ backend: origin: https://your-public-url.com:3000 ``` -If the protocole is `http`, you will need to set `backend.csp.upgrade-insecure-requests` to `false` as well. +If the protocol is `http`, you will need to set `backend.csp.upgrade-insecure-requests` to `false` as well. -The app port must proxy websocket connection in order to have hot reloading. +The app port must proxy websocket connections in order to make hot reloading work. From a908e00e5fc1741ed3ece43fe01f85173a5838c7 Mon Sep 17 00:00:00 2001 From: "r.bideau" <7304827+rbideau@users.noreply.github.com> Date: Wed, 24 Feb 2021 19:16:54 +0100 Subject: [PATCH 4/5] Fix some other typo and add theia to vocab Signed-off-by: r.bideau <7304827+rbideau@users.noreply.github.com> --- .github/styles/vocab.txt | 1 + contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/styles/vocab.txt b/.github/styles/vocab.txt index 2e0bd13962..831df202e1 100644 --- a/.github/styles/vocab.txt +++ b/.github/styles/vocab.txt @@ -255,6 +255,7 @@ techdocs templated templater templaters +theia toc tolerations toolchain diff --git a/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md b/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md index de8a99e35d..cda74e928f 100644 --- a/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md +++ b/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md @@ -65,7 +65,7 @@ If your development environment is in the cloud (like with [AWS Cloud9](https:// In `app-config.local.yaml`, you will probably need to make some changes, the exact values will depend on your setup. -For instance, if your public url is `https://your-public-url.com` and the port `3000` and `8080` are proxified as is: +For instance, if your public url is `https://your-public-url.com` and the port `3000` and `8080` are open: ```yaml app: @@ -83,4 +83,4 @@ backend: If the protocol is `http`, you will need to set `backend.csp.upgrade-insecure-requests` to `false` as well. -The app port must proxy websocket connections in order to make hot reloading work. +The app port must proxy web socket connections in order to make hot reloading work. From f90a49fb8af992c2b80a399e36e098f8d76fdbc5 Mon Sep 17 00:00:00 2001 From: "r.bideau" <7304827+rbideau@users.noreply.github.com> Date: Wed, 24 Feb 2021 20:32:13 +0100 Subject: [PATCH 5/5] Rephrase config advice in contrib doc for proxy Signed-off-by: r.bideau <7304827+rbideau@users.noreply.github.com> --- contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md b/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md index cda74e928f..bee0a84fe6 100644 --- a/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md +++ b/contrib/docs/tutorials/help-im-behind-a-corporate-proxy.md @@ -63,9 +63,8 @@ if (process.env.HTTPS_PROXY) { If your development environment is in the cloud (like with [AWS Cloud9](https://aws.amazon.com/cloud9/) or an instance of [Theia](https://theia-ide.org/)), you will need to update your configuration. -In `app-config.local.yaml`, you will probably need to make some changes, the exact values will depend on your setup. - -For instance, if your public url is `https://your-public-url.com` and the port `3000` and `8080` are open: +You will probably need to make some changes in `app-config.yaml` (or another config file like `app-config.local.yaml` if you've created it, see the [configuration doc](https://backstage.io/docs/conf/#supplying-configuration)). +The exact values will depend on your setup but for instance, if your public url is `https://your-public-url.com` and the port `3000` and `8080` are open: ```yaml app: