Summary
When behind a corporate firewall, all development tasks become burdened with the efforts of adapting to the restraints imposed from a security minded perspective. Such is the case when accessing a simple site through a node express proxy server when the site is guarded by a corporate firewall.
Objective
- Create express proxy server (http://my.example.com)
- On client request, reach a known backend server to pull resources (http://example.com)
- From proxy server, amend and add resources
- Forward amended resources to client browser
Problem
Accessing a backend server via an express proxy.
Symptoms
When running the proxy server and making a request to https://my.example.com, the proxy server internally returns the exception:
..\node_modules\http-proxy\lib\http-proxy\index.js:119
throw err;
^
Error: connect ETIMEDOUT 10.10.10.10:443
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
Additionally, the browser receives the following error (as indicated by using Chrome’s developer tools):
Solution
The proxy server must include code that takes into account the corporate proxy server.
https://gist.github.com/jakelly/31c9f908eddb07275dc3de8117bf5b41
Conclusion
By providing in the options to the httpProxy.CreateProxyServer method the correct proxy information in the agent attribute, you can bypass this hurdle and continue churning out stellar code!