How to run a http proxy on Nodester?

45 views
Skip to first unread message

Kelvin Chen

unread,
Jun 19, 2012, 10:15:31 AM6/19/12
to node...@googlegroups.com
i create a http proxy on Nodester.
The code is simple: 

var http = require('http');
var httpProxy = require('http-proxy');
var proxy = 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 not work, always return "404 Not Found". (http-proxy installed and app log doesn't show any error)
If i run it locally and set my browser's proxy to 127.0.0.1:8080, it works fine.
Is there anything wrong? How to make my proxy run?
Thanks!


 

Alejandro Morales Gámez

unread,
Jun 20, 2012, 11:38:16 AM6/20/12
to node...@googlegroups.com
Proxyception :P 

Sorry! Out of jokes.

Your app should no matter what show a 503 if it's failing. If nodester 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 on you. Anyway try that, and also let me know what the logs are saying.


/be

Kelvin Chen

unread,
Jun 21, 2012, 2:22:44 AM6/21/12
to node...@googlegroups.com
i add some logs:
 
var http = require('http');
var httpProxy = require('http-proxy');
var proxy = 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 "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
 
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 logs again, the result is no new logs output, the app seems does not receive any request.

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?

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

Or Nodester can not do this? Only web apps?

在 2012年6月20日星期三UTC+8下午11时38分16秒,Alejandro Morales Gámez写道:
Reply all
Reply to author
Forward
0 new messages