0

I am trying to implement a node http proxy for the first time with my simple twitter tweeter. I have never used this before and tried following the docs (https://github.com/nodejitsu/node-http-proxy) with no luck. Can anyone point me in the right direction? Also, is it okay to run this locally on a mac? Thanks

var express = require('express');
var app = express();
var port = 8300;
var twitter = require('twitter');
var twit = new twitter({  keys and stuff })


var http = require('http'),
httpProxy = require('http-proxy');


twit.post('statuses/update', {status: "Hello world!"}
//this works



httpProxy.createProxyServer({target:'http://localhost:3000'}).listen(3000); 



// Create your target server--- WHat exactly does this mean??

http.createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));

  res.end();
}).listen(3000);
2
  • Why do you use http-proxy? You want to create your own proxy-server or just proxy your request to twitter? Commented Jul 12, 2016 at 5:12
  • I'd like to proxy my request to twitter. Commented Jul 12, 2016 at 5:25

1 Answer 1

1

You should not use this lib for proxing you request. This lib is for make your own proxy server. Look at example how to use proxy with twitter lib

Sign up to request clarification or add additional context in comments.

5 Comments

Ok, what would be the difference between using a server and proxy the request? Trying to keep IP changing / difficult to trace
For your porposes you need to proxy your requests. Of course, you need a proxy server to send requests through. Such proxy server can be found in public/private proxy lists or you can make your own using VPS. You should have something like yourApp -> proxy(ies) -> twitter. Keep in mind that you would be able to tracked if you had use one credentials for all requests
great thanks- what do you mean by credentials? API keys? How would one get around that?
Yes, API keys. It all depends on your porposes. If you don't want to be tracked by Twitter you should use different API keys for different IP addresses. For this you just need manualy create it for each Proxy server you have and then handle it in your app like [{proxy: your_proxy, keys: your_keys}, ...].
Promblem with free proxies is that they often too slow or have short life. See that updateble list, for example proxylist.hidemyass.com/search-1302870#listable . You need http/https proxies (it seems twitter lib don't support socks proxies). If you don't want only to experiment but get it to production, I strongly recommend to buy proxy/make your own with VPS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.