Note that there are some explanatory texts on larger screens.

plurals
  1. POhttp.get through vpn + node
    primarykey
    data
    text
    <p>I want to be able to do a http.get request through node within my own vpn, but it seems likes the function is passing the website to a dns instead of look in my vpn. This following code works with google as the host.</p> <pre><code>http = require('http'); var host = "www.google.com"; var options = {host:host, port:80, path:'/'} http.get( options, function( res ){ res.setEncoding('utf8'); res.on( 'data', function( chunk ){ console.log( chunk ); }); }); </code></pre> <p>but when I change host to a_site_on_my_vpn.com it throws a Domain name not found error, but when i type a_site_on_my_vpn.com on firefox I am able to load the page. I guess one way I can fix this is to find out the host name's ip but is there an easier way? :D</p> <p>I resolve my own answer, but to answer the question in the follow up, the answer is yes here is a snippet that shows that, by doing an DNS ip lookup then going to google by IP.</p> <pre><code>var dns = require('dns'); var http = require('http'); dns.resolve4('www.google.com', function (err, addresses) { if (err) throw err; console.log('addresses: ' + JSON.stringify(addresses)); var options = { host: addresses[0] } http.get(options, function(res){ console.log("Sending http request to google with options", options); var htmlsize = 0; res.on('data', function( chunk ){ htmlsize+=chunk.length; }); res.on('end', function(){ console.log( "got html of lenght", htmlsize ); }); }); }); </code></pre> <p>And this is the output </p> <pre><code>addresses: ["74.125.224.82","74.125.224.81","74.125.224.84","74.125.224.80","74.125.224.83"] Sending http request to google with options { host: '74.125.224.82' } got html of lenght 33431 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload