Internal proxy server doesn't work if http proxy is set
See original GitHub issueInternal code-server’s proxy for accessing services doesn’t work if http proxy is configured.
Test case:
- create vscode extension that runs http server that returns “ok” on /status route, bind the server to port 3000
- install the extension into code-server
- run code-server --auth=none -vvv (so curl examples below work w/ auth) from an environment where http_proxy, https_proxy and no_proxy is set (ensure address 0.0.0.0 is in no_proxy)
- curl http://localhost:3000/status
- => you get OK response
- now (assuming code-server runs on port 7777) via proxy: curl http://localhost:7777/proxy/3000/status
- => you get 500 response with message “Maximum callstack exceeded”
Following code calls itself in an endless loop:
at ProxyAgent.callback (/usr/local/Cellar/code-server/3.10.2/libexec/node_modules/proxy-agent/index.js:215:11)
at /usr/local/Cellar/code-server/3.10.2/libexec/node_modules/agent-base/dist/src/promisify.js:6:16
at new Promise (<anonymous>)
at ProxyAgent.promisifiedCallback (/usr/local/Cellar/code-server/3.10.2/libexec/node_modules/agent-base/dist/src/promisify.js:5:16)
at ProxyAgent.addRequest (/usr/local/Cellar/code-server/3.10.2/libexec/node_modules/agent-base/dist/src/index.js:187:38)
at ProxyAgent.callback (/usr/local/Cellar/code-server/3.10.2/libexec/node_modules/proxy-agent/index.js:215:11)
at /usr/local/Cellar/code-server/3.10.2/libexec/node_modules/agent-base/dist/src/promisify.js:6:16
at new Promise (<anonymous>)
at ProxyAgent.promisifiedCallback (/usr/local/Cellar/code-server/3.10.2/libexec/node_modules/agent-base/dist/src/promisify.js:5:16)
The reason is monkey patching of http(s).globalAgent done in proxy_agent.js
.
The code in node_modules/proxy-agent/index.js
(#httpOrHttps) is supposed to return bare http(s).globalAgent in case the processed http request is not supposed to be proxied but it returns the monkey patched instance which is the initiator of the call.
A very ugly workaround is to ensure proxy_agent#shouldEnableProxy returns false by adding “example.com” to no_proxy as the code comment suggests 😃
// But that's drastically unlikely.
function shouldEnableProxy() {
...```
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Internal proxy server doesn't work if http proxy is set #3662
Internal code-server's proxy for accessing services doesn't work if http proxy is configured. Test case: create vscode extension that runs ...
Read more >How to Fix “There Is Something Wrong With the Proxy Server ...
1. Check if You Have a Stable Internet Connection · 2. Restore Your Proxy Server to Its Default Settings · 3. Disabling Your...
Read more >Fix: No Internet, There Is Something Wrong With Proxy Server
1. Check your internet connection or proxy settings · Click on the Start menu, type Internet Options, and then open it from the...
Read more >How to Fix Unable to Connect to the Proxy Server | VSS Guide
If you are still unable to connect to proxy server, you can clear the browser cache. Clearing browser cache will remove corrupt scripts...
Read more >Internal web server not accessible through my organisation's ...
If the web server is only internal, and the proxy server just allow access to internet sites, then you cannot configure the web...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can’t promise when we will get to this, but I’ll move it to “On Deck” meaning it’s ready to be placed in an upcoming version milestone.
hey! thanks a lot @mfukala for this workaround! it would have taken me hours to come up with such a solution. I can confirm that setting an environment variable like
NO_PROXY=example.com, <some-other-domains>
works well!Are there any ideas how to solve this? Or is this part of the investigation in #3841?