Node-http-proxy: "Direct IP access not allowed" when reverse proxying to CloudFlare domain

Created on 20 Feb 2015  路  2Comments  路  Source: http-party/node-http-proxy

The following code successfully creates a reverse proxy server on localhost:8000 which reverse proxies to httpbin.org:

var httpProxy = require('http-proxy');
httpProxy.createProxyServer({target: 'http://httpbin.org'}).listen(8000);

However, if you change http://httpbin.org to any CloudFlare-enabled site (including http://www.cloudflare.com itself), you get "Error 1003 Direct IP access not allowed". Is there some way to configure the proxy server so it can successfully front CloudFlare-enabled sites? Sorry if I'm missing something obvious.

Most helpful comment

Never mind, seem to have figured it out:

httpProxy.createServer({changeOrigin: true, target: 'http://www.cloudflare.com'}).listen(8000);

All 2 comments

Never mind, seem to have figured it out:

httpProxy.createServer({changeOrigin: true, target: 'http://www.cloudflare.com'}).listen(8000);

Hey, I know it's been 5 years, But it's somehow directing me to the URL instead of staying on the proxy.
Weird. Do you have any idea why?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

miton18 picture miton18  路  5Comments

guillaume-at-palo picture guillaume-at-palo  路  4Comments

catamphetamine picture catamphetamine  路  6Comments

sisyphsu picture sisyphsu  路  3Comments

karthikus picture karthikus  路  3Comments