Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How to run a http proxy on Nodester?

Date: Wed, 20 Jun 2012 23:22:44 -0700 (PDT)
From: Kelvin Chen <kowoc...@gmail.com>
To: nodester@googlegroups.com
Message-Id: <71768ec1-6015-4104-9625-3a0e291c983d@googlegroups.com>
In-Reply-To: <213e28bb-e9c5-4eb6-965e-cf14479b0f05@googlegroups.com>
References: <2914e364-2ee7-40e6-a5f5-b8154237af07@googlegroups.com>
 <213e28bb-e9c5-4eb6-965e-cf14479b0f05@googlegroups.com>
Subject: Re: How to run a http proxy on Nodester?
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1974_10585449.1340259764937"

------=_Part_1974_10585449.1340259764937
Content-Type: multipart/alternative; 
	boundary="----=_Part_1975_4052678.1340259764937"

------=_Part_1975_4052678.1340259764937
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

i add some logs:
=20

> var http =3D require('http');
> var httpProxy =3D require('http-proxy');
> var proxy =3D new httpProxy.RoutingProxy();
> http.createServer(function(req, res) {
>     console.log("ready to proxy req to", req.headers['host']);
>     proxy.proxyRequest(req, res, {
>         host: req.headers['host'],
>         port: 80
>     });
> }).listen(process.env.app_port || 8080);
> console.log("proxy is running");


If run it locally, set the browser's proxy to localhost, and visit=20
"www.google.com", the log says:

proxy is running
> ready to proxy req to www.google.com
> ready to proxy req to www.google.com
> ready to proxy req to www.google.com

=20
If run it on Nodester, the log says:

nodester info Showing logs for: kapp
> New PID: 7659
> chroot_runner
> chroot_runner
> Spawing /app/test.js
> Running node v-0.6.17
> proxy is running


Then set the browser's proxy to Nodester, and visit "www.google.com". Check=
=20
logs again, the result is no new logs output, the app seems does not=20
receive any request.

I know that Nodester setup an association between "appname.nodester.com:80"=
=20
and "the_actual_app_host:app_port", but it seems can not transparently=20
route http requests?

Purpose: Because i can not visit some sites directly from my host, i just=
=20
want setup a http proxy on Nodester to route http requests to these sites.

Or Nodester can not do this? Only web apps?

=E5=9C=A8 2012=E5=B9=B46=E6=9C=8820=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=89UTC+=
8=E4=B8=8B=E5=8D=8811=E6=97=B638=E5=88=8616=E7=A7=92=EF=BC=8CAlejandro Mora=
les G=C3=A1mez=E5=86=99=E9=81=93=EF=BC=9A
>
> Proxyception :P=20
>
> Sorry! Out of jokes.
>
> Your app should no matter what show a 503 if it's failing. If nodester=20
> returns you a 404 is because the app don't exists.
>
>
> Try to list your apps to see if the app is created. ("$ nodester apps")
>
> I don't understand what's the purpose of the proxy in your app, but that'=
s=20
> on you. Anyway try that, and also let me know what the logs are saying.
>
>
> /be
>
> On Tuesday, June 19, 2012 8:15:31 AM UTC-6, Kelvin Chen wrote:
>>
>> i create a http proxy on Nodester.
>> The code is simple:=20
>>
>> var http =3D require('http');
>>> var httpProxy =3D require('http-proxy');
>>> var proxy =3D new httpProxy.RoutingProxy();
>>> http.createServer(function(req, res) {
>>>     proxy.proxyRequest(req, res, {
>>>         host: req.headers['host'],
>>>         port: 80
>>>     });
>>> }).listen(process.env.app_port || 8080);
>>
>>
>> Then i set my browser's proxy to myproxy.nodester.com:80, but it does=20
>> not work, always return "404 Not Found". (http-proxy installed and app l=
og=20
>> doesn't show any error)
>> If i run it locally and set my browser's proxy to 127.0.0.1:8080, it=20
>> works fine.
>> Is there anything wrong? How to make my proxy run?
>> Thanks!
>>
>>
>> =20
>>
>
------=_Part_1975_4052678.1340259764937
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<div>i add some logs:</div><div>&nbsp;</div><blockquote class=3D"gmail_quot=
e" style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-=
color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">v=
ar http =3D require('http');<br>var httpProxy =3D require('http-proxy');<br=
>var proxy =3D new httpProxy.RoutingProxy();<br>http.createServer(function(=
req, res) {<br>&nbsp; &nbsp; console.log("ready to proxy req to", req.heade=
rs['host']);<br>&nbsp; &nbsp; proxy.proxyRequest(req, res, {<br>&nbsp; &nbs=
p; &nbsp; &nbsp; host: req.headers['host'],<br>&nbsp; &nbsp; &nbsp; &nbsp; =
port: 80<br>&nbsp; &nbsp; });<br>}).listen(process.env.app_port || 8080);<b=
r>console.log("proxy is running");</blockquote><div><br></div><div>If run i=
t locally,&nbsp;set the browser's proxy to localhost,&nbsp;and&nbsp;visit "=
www.google.com", the log says:</div><div><br></div><blockquote class=3D"gma=
il_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; borde=
r-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1=
ex; ">proxy is running<br>ready to proxy req to www.google.com<br>ready to =
proxy req to www.google.com<br>ready to proxy req to www.google.com</blockq=
uote><div>&nbsp;</div><div>If run it on Nodester, the log says:</div><div><=
br></div><div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0p=
x 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); bor=
der-left-style: solid; padding-left: 1ex; ">nodester info Showing logs for:=
 kapp<br>New PID: 7659<br>chroot_runner<br>chroot_runner<br>Spawing /app/te=
st.js<br>Running node v-0.6.17<br>proxy is running</blockquote></div><div><=
br></div><div>Then set the browser's proxy to Nodester, and visit "www.goog=
le.com". Check logs again, the result is no new logs output, the app seems =
does not receive any request.</div><div><br></div><div>I know that Nodester=
 setup an association between "appname.nodester.com:80" and "the_actual_app=
_host:app_port", but it seems can not transparently route http requests?</d=
iv><div><br></div><div>Purpose: Because i can not visit some sites directly=
 from my host, i just want setup a http proxy on Nodester to route http req=
uests to these sites.</div><div><br></div><div>Or Nodester can not do this?=
 Only web apps?</div><br>=E5=9C=A8 2012=E5=B9=B46=E6=9C=8820=E6=97=A5=E6=98=
=9F=E6=9C=9F=E4=B8=89UTC+8=E4=B8=8B=E5=8D=8811=E6=97=B638=E5=88=8616=E7=A7=
=92=EF=BC=8CAlejandro Morales G=C3=A1mez=E5=86=99=E9=81=93=EF=BC=9A<blockqu=
ote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left=
: 1px #ccc solid;padding-left: 1ex;">Proxyception :P&nbsp;<div><br></div><d=
iv>Sorry! Out of jokes.</div><div><br></div><div>Your app should no matter =
what show a 503 if it's failing. If nodester returns you a 404 is because t=
he app don't exists.</div><div><br></div><div><br></div><div>Try to list yo=
ur apps to see if the app is created. ("$ nodester apps")</div><div><br></d=
iv><div>I don't understand what's the purpose of the proxy in your app, but=
 that's on you. Anyway try that, and also let me know what the logs are say=
ing.</div><div><br></div><div><br></div><div>/be<br><br>On Tuesday, June 19=
, 2012 8:15:31 AM UTC-6, Kelvin Chen wrote:<blockquote class=3D"gmail_quote=
" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div>i create a http proxy on Nodester.</div><div>The code is simpl=
e:&nbsp;</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,2=
04);border-left-style:solid;padding-left:1ex">var http =3D require('http');=
<br>var httpProxy =3D require('http-proxy');<br>var proxy =3D new httpProxy=
.RoutingProxy();<br>http.createServer(function(<wbr>req, res) {<br>&nbsp; &=
nbsp; proxy.proxyRequest(req, res, {<br>&nbsp; &nbsp; &nbsp; &nbsp; host: r=
eq.headers['host'],<br>&nbsp; &nbsp; &nbsp; &nbsp; port: 80<br>&nbsp; &nbsp=
; });<br>}).listen(process.env.app_port || 8080);</blockquote><div><br></di=
v><div>Then i set my browser's proxy to <a href=3D"http://myproxy.nodester.=
com:80" target=3D"_blank">myproxy.nodester.com:80</a>, but it does not work=
, always return "404 Not Found". (http-proxy installed and&nbsp;app log doe=
sn't show any error)</div><div>If i run it locally and set&nbsp;my browser'=
s proxy to <a href=3D"http://127.0.0.1:8080" target=3D"_blank">127.0.0.1:80=
80</a>, it works fine.</div><div>Is there anything wrong? How to make my pr=
oxy run?</div><div>Thanks!</div><div><br></div><div><br></div><div>&nbsp;</=
div></blockquote></div></blockquote>
------=_Part_1975_4052678.1340259764937--

------=_Part_1974_10585449.1340259764937--