Trying to capture node.js http traffic with a protocol analyser (Charles) but can't get node to use proxy - http

i'm trying to capture node.js http traffic with a protocol analyser (Charles) but can't get node to use the proxy. Is there some way to get nodes http and https modules to use a proxy?
I'm using OSX by the way

Thanks Chris in my case I was using Charles and Request module. There is a handle proxy option to put your charles port.
So to find your port in the Charles menu Proxy->Proxy Settings->Http Proxy
Use this port number in any request eg:
request.get(url, {
'proxy': 'http://localhost:<charles-proxy-port>'
}, function (error, response, body) {
//did you see me in Charles??
});

Figured it out. I was following the instructions from How can I use an http proxy with node.js http.Client?
And i thought i needed to use https to access the proxy. But if i use http to access the proxy, and pass eg 'path: 'https://www.google.com/accounts/OAuthGetRequestToken', then it works...

Related

I need http port forward proxy server golang

I need http port forward proxy server golang
Be able to provide Rest http api
Kind of like
PortForward Traffic Forwarding
Please tell me the program that can be used directly.
thanks

Rewrite WebSocket messages via Nginx?

Is it possible to rewrite the content of a websocket message proxied through Nginx?
For example, say I've sent a message with the contents JSON.stringify({ auth: 'someIdKey' }). On Nginx, I would to substitute the value of someIdKey to someJwt, then forward it to the proxied upstream resource. I'd also want to do the reverse translation when the upstream resource sends out messages back to the client.
I know how to do this (and am doing this) for HTTP requests, rewriting custom headers to do an on-the-fly translation, but I'm not sure how to approach carrying over the pattern to websocket communication.
I'm using OpenResty as my Nginx distribution and am passably-ok at Lua scripting.
Would appreciate any ideas/help.
You can use https://github.com/openresty/lua-resty-websocket module.
It has both server and client side non-blocking API. So you can program anything you want.

Can I send carbon/graphite data to a url on port 80?

I work in an environment where ports are closed and difficult to get open.
I was thinking of sending my graphite data to localhost/graphitein rather than port 2003 and have nginx do the mapping.
Is there any reason not to do this?
According to the Wikipedia (bold is mine):
Nginx [...] can also act as a reverse proxy server for HTTP, HTTPS,
SMTP, POP3, and IMAP protocols, as well as a load balancer and an
HTTP cache.
I don't think you can use Nginx as a reverse proxy for the Graphite protocol.
Perhaps you can use an SSH Tunnel?
This tool could be a solution https://github.com/obfuscurity/backstop "Backstop is a simple endpoint for submitting metrics to Graphite. It accepts JSON data via HTTP POST and proxies the data to one or more Carbon/Graphite listeners."

Why are browser requests not going through my proxy server?

I tried writing a simple proxy in node.js today with a basic HTTP server, I realized in Firefox when I reload the proxy, I can see a request. However, when I load any page, it doesn't seem to be going through my proxy. I can curl the server, and it works fine. But why is the browser not using my proxy?
The code just looks like:
var http = require('http');
var listener = function(request, response) {
console.log('hi');
response.write("200");
response.end();
};
var server = http.createServer(listener);
server.listen(8000, undefined, function() {
console.log('Server has started on 8000');
});
I'm just looking for something that changes the header of the request, though a reverse proxy would also be cool.
Edit: This is how I'm pointing my browser to my proxy. In Firefox, preferences -> advanced -> Network -> Settings
I tried to setting the HTTP Proxy under "Manual proxy configuration" to 127.0.0.1:8000 - that seems to do something, cuz all my pages fail to load, but I don't see any activity on my proxy server.
I also tried to just put 127.0.0.1:8000 under "Automatic proxy configuration URL" which sends a request when I just configure it, but nothing is proxied afterwards. I'm wonder what kind of response the "automatic" configuration is looking for...
The code you have written isn't a proxy server? It's just an HTTPd responder, which is why your curl script 'works' but firefox doesn't
Taking an example already online, http://catonmat.net/http-proxy-in-nodejs, you will see that as well as setting up the HTTPd in node, you have the dispatch HTTP calls to the server being proxied and drain that output back into the response to your browser.
In firefox, you want to set Manual Proxy configuration -> Http Proxy: 127.0.0.1 and your Port 8000
Check "Use this proxy server for all protocols"
That works for me :)
Maybe you have another server running on 8000 ?
To use Charles to capture traffic to localhost you need to use http://localhost./ (yes, with a dot on the end).
See the documentation here:
http://www.charlesproxy.com/documentation/faqs/localhost-traffic-doesnt-appear-in-charles

How can i debug HTTP sessions using Fiddler, just like i did with TcpTrace?

Im trying to stop using TcpTrace and start working with Fiddler.
But i just can't setup fiddler to just start listening specified port and redirect all requests to the specified WS with another port.
All i want is just redirect and monitor all traffic from localhost:4747 -> webservice-ip:10000
Is there any solution for my problem ?
Thanks in advance.
Set Fiddler to listen on port 4747, and then edit your CustomRules.js (menu->Rules->Customize Rules). Putting something like this into the OnBeforeRequest method should help:
if (oSession.host=="localhost:4747") {
oSession.host="external:1000";
}
if you want all traffic passing through Fiddler to go to the external host, you can simply use
oSession.host="external:1000";
(where external is the hostname of the external host)

Resources