2

I'm trying to use NORD VPN proxy to make a request in ruby. The proxy is good, I've tested it successfully with curl as well as in a python script.

However, I'm not able to make it work in ruby and I suspect it has to do with the odd port (89) used in the proxy since I've done this successfully in ruby before using port 80.

Any advice is welcome, hopefully you're able to point out a flaw in my code!

require "uri"
require 'net/http'

proxy_host = 'no179.nordvpn.com'
proxy_port = 89
proxy_user = 'user'
proxy_pass = 'pass'

uri   = URI.parse("https://api.ipify.org/")
proxy = Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_pass)

req = Net::HTTP::Get.new(uri.path)

result = proxy.start(uri.host, uri.port) do |http|
  http.request(req)
end

Error:

3.0.2/lib/ruby/gems/3.0.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:227:in 'rbuf_fill': end of file reached (EOFError)

As a side note I felt it worth mentioning I've tried the following http clients with the same results:

  • HTTParty (same error)
  • Faraday (same error)
  • http.rb
    • 3.0.2/lib/ruby/gems/3.0.0/gems/http-5.0.4/lib/http/connection.rb:108:in 'read_headers!': couldn't read response headers (HTTP::ConnectionError)

Ruby version: 3.0.2

lyf1n
  • 81
  • 1
  • 5

1 Answers1

0

I don't own a NordVPN account so I can't really test, but it looks like they are shutting down the HTTP proxies https://nordvpn.com/es/blog/removing-http-proxies/

I would suggest you to try first the SOCK proxies with this https://net-ssh.github.io/ssh/v2/api/classes/Net/SSH/Proxy/SOCKS5.html

javiyu
  • 1,336
  • 6
  • 9
  • Like I said, I already tested the proxy with both curl and a separate python script successfully- so the proxy is good. Thanks for the thought though :) I'll definitely check it out! – lyf1n Jan 16 '22 at 16:03
  • Looks like `Proxy` class is being deprecated, you need to call the `new` method with the the proxy host, port, user and pass https://ruby-doc.org/stdlib-2.4.2/libdoc/net/http/rdoc/Net/HTTP.html#method-c-new – javiyu Jan 17 '22 at 12:04