Skip to content
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

Isomorphic-fetch prevents outline from running behind a proxy #1893

Closed
thllwg opened this issue Feb 16, 2021 · 2 comments · Fixed by #2044
Closed

Isomorphic-fetch prevents outline from running behind a proxy #1893

thllwg opened this issue Feb 16, 2021 · 2 comments · Fixed by #2044
Assignees
Labels
bug self-hosted Issues related to self-hosting the code

Comments

@thllwg
Copy link

thllwg commented Feb 16, 2021

Preface: I am not a node developer and my analysis may be based on wrong assumptions.

I'm trying to run a self-hosted version of outline. The server runs behind a corporate proxy. Consequently, I've set environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY). I can reach outline's login-page from the internet without any problems and (upon clicking "login with slack") are forwarded to slack to allow access to the workspace. However, it appears that while outline is reachable from the internet, outline itself is not able to reach the internet and thus cannot make use of slacks callback url. See corresponding log:

outline_1   | ClientError [BadRequestError]: request to https://slack.com/api/oauth.access?client_id=*****************.*****************&client_secret=*********************************&redirect_uri=http%3A%2F%2F******.*********.**%3A30705%2Fauth%2Fslack.callback&code=***************.******************.************************* failed, reason: connect ETIMEDOUT 3.123.248.34:443
outline_1   |     at new InvalidRequestError (/opt/outline/build/server/errors.js:51:34)
outline_1   |     at request (/opt/outline/build/server/slack.js:49:11)
outline_1   |     at processTicksAndRejections (internal/process/task_queues.js:93:5)
outline_1   |     at async /opt/outline/build/server/auth/slack.js:66:16
outline_1   |     at async /opt/outline/node_modules/koa-mount/index.js:58:5 {
outline_1   |   id: 'invalid_request',
outline_1   |   headerSent: true
outline_1   | }

Upon further inspection, I learned that Nodejs doesn't respect HTTP_PROXY environment variables and developers are responsible themselves to support operations behind a proxy (nodejs/node/issues/8381). Outline uses the isomorphic-fetch package to handle the communication with the slack API. Unfortunately, isomorphic-fetch does not read HTTP_PROXY environment variables either (matthew-andrews/isomorphic-fetch/issues/171). By replacing isomorphic-fetch with fetch-with-proxy, I got outline running behind a proxy (see fork: dad89f8 and bddefc4).
However, this proof of concept is probably still hacky.

Expected behavior
Outline should respect http_proxy environment variables.

Outline (please complete the following information):

  • Install: self-hosted
  • Version: 4b60346
@thllwg thllwg added the bug label Feb 16, 2021
@tommoor tommoor added the self-hosted Issues related to self-hosting the code label Feb 16, 2021
@tommoor
Copy link
Member

tommoor commented Feb 16, 2021

Hi @thllwg – your analysis and solution seems correct. Swapping out the dep will need more testing to ensure it does not regress other situations. Would you like to put a PR in?

@stale
Copy link

stale bot commented Apr 17, 2021

Hey! The issue has been automatically marked as stale because it has not had recent activity. It will be closed soon if no further activity occurs. Please reply here if you wish for the issue to be kept open.

@stale stale bot added the stale label Apr 17, 2021
tommoor added a commit that referenced this issue Apr 17, 2021
closes #1893

For some fun discussion on why this is required, see this issue: nodejs/node#8381
@tommoor tommoor removed the stale label Apr 17, 2021
@tommoor tommoor self-assigned this Apr 17, 2021
tommoor added a commit that referenced this issue May 13, 2021
* fix: Add server-side proxy support via fetch-with-proxy

closes #1893

For some fun discussion on why this is required, see this issue: nodejs/node#8381

* lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug self-hosted Issues related to self-hosting the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants