Using IP Proxy with Ruby on Rails - ruby-on-rails

How would one go about using another IP address to make API calls? I want to hide my original IP.
Maybe some vpn service or gem?
I am using an Amazon API gem but want to make sure I can't get traced to the usual IP that I use. I would like to be making requests from an IP that I can buy/lease, for example.
I have looked into this here: https://github.com/ankane/ip_anonymizer ...but not sure if this will do what I want it to do.
Any feedback or suggestions? Thanks!

Related

Forcing Gibbon Gem (or Faraday) to use QuotaGuard Static HTTP proxy on Heroku

Full disclaimer; I'm not a strong Ruby dev, but I am learning quickly :)
I've set up a simple Ruby script on a Heroku dyno that listens for calls from our donation platform.
When a donation is made, it hits a webhook endpoint within my app, which then sends a donation receipt via Mandrill (which works fine), and updates/inserts a record in a Mailchimp list, via the 'upsert' method of the wonderful Gibbon gem.
That all works fine; except when the Heroku box happens to come up on an IP address that has done something bad in the past, and Mailchimp's API drops with a 403 (Forbidden) error.
I've had this confirmed by the Mailchimp API team; they suggest using something like QuotaGuard Static to tunnel the API requests to Mailchimp through, removing the issue of API calls from inconsistent (and sometimes untrusted) IP addresses.
I'd love some advice on how to make this happen. I can see that Gibbon uses Faraday to handle HTTP requests, but I'm not an advanced enough Ruby dev to fork the code and add in HTTP proxy functionality.
If there's a way to globally force the Faraday calls to use a HTTP proxy (ie QuotaGuard Static), that's what I'm looking for. A config setting for Faraday, for example.
Or perhaps there's a tweak I can make to my Procfile:
web: bundle exec ruby webhooks.rb -p $PORT
...that will force the outbound traffic to go via the QuotaGuard Static proxy. I know Proximo has this functionality, but it also blocks inbound access to the app, which doesn't work for this app.
Appreciate any ideas the community can offer. Thanks!
Gibbon Author here. You can simply set the proxy value to the proxy URL in Gibbon 2.2.0 and later.
From the Faraday documentation (here) the Connectionclass uses the proxy specified in the http_proxy environment variable. I have never tried it, but looking at the source code it should work.
I wanted to provide a bit more information, since the two answers pointed me on the right track but still required me to do some digging. I solved this issue by first adding the QuotaGuard Static add-on in Heroku (free for up to 250 uses per month) and then initializing Gibbon like so:
g = Gibbon::Request.new
g.proxy = ENV["QUOTAGUARDSTATIC_URL"]
And here is the relevant section from the Gibbon docs: https://github.com/amro/gibbon#other

Running a live Rails environment

I'm new to web development, rails, etc. I have what is probably a very dumb questions but I searched and was not able to find the specific answer, though there's a good chance I asked the wrong question.
I'm following this tutorial which wants you to create a test rails app locally and view it via localhost in a browser. However I am learning directly on the server itself. This is because currently I only have an iPad to work with, but I've been able to do everything directly on the server itself using Panic's Prompt. To continue with these lessons I need to be able to see what I've done via a browser which since I can't use localhost, I want to see directly on my server. Here is the tutorial I'm following:
http://installfest.railsbridge.org/installfest/create_a_rails_app
Here is my website:
redvardo.com
Any help or pointers toward the correct information would be helpful. Please tell me if I did not include enough information as well. Thanks!
If your server provides a public IP address, use that ip to access the project. First of all make sure the brick server is running via rails s then you can go ahead and access the page directly via the ip: 12.13.31.115:3000 for example. This would be the fastest way, otherwise you need to setup dns to point to your server via your domain name registrar.
Hope that helps.
Thanks for the help but for me, what I did was simply install a VNC server on the server itself, now I can view localhost on the server for everything the tutorials are asking.

How to setup QuotaGuard Static for a Rails app hosted on heroku?

I'm trying to setup my heroku app to have an static IP using QuotaGuard (I know proximo is the other option, but it's pretty expensive).
I added the heroku QuotaGuard Static addon and got the two IPs it generates as well as the proxy url.
What is my next step? (aka how do I tell my Rails app to use the proxy provided by QuotaGuard)
I see they have ruby code samples using REST-client and HTTParty, but do I put that somewhere like in the application.rb??
Most likely a bit too late to answer this question, but still.
Like you said, the first step to configuring QuotaGuard Static is provisioning the addon on Heroku (either via the Web Interface or the Heroku CLI). From there, you are able to get your two outbound IPs, and your proxy URL. The two IPs you were given should be whitelisted on whichever remote service you are trying to access.
As you mentioned, the documentation gives you a couple of samples using Rest Client for Ruby on Rails. This snippet should pretty much go anywhere you want to access whichever resource you need to access via the static IP Addresses. Assuming you want to access a Web Service hosted on an Amazon EC2 instance with elastic IP 1.2.3.4, your would write:
RestClient.proxy = ENV["QUOTAGUARDSTATIC_URL"]
res = RestClient.get("http://1.2.3.4/yourWebService")
And from there process the response stored in res appropriately. This code would go in say whichever controller's method you'll be using to access the remote web service. In this case, you also need to add the Rest Client to your controller, so at the top of that file you shoud also add require "rest-client" . Don't forget to add the rest-client gem to your Gemfile.
Summing up, basically the snippets from the documentation go wherever it is you want to use the proxy to access a remote service requiring a fixed, whitelisted set of IP addresses.
Source: https://devcenter.heroku.com/articles/quotaguardstatic

How to set up my xampp so that when i type my ip to get my custom made site

What i want to do is to set xampp so that when i give my ip to someone they can access my site. The reason for me to find something like this is cause i want to embed paypal testing to my site and it is needed to set a URL for the customers to return to my site when they complete their transactions... I run XAMPP 1.7.7 and my modem is a siemens. Also is there any free way to get a url ie blahblahblah.net or something like this?
In order to do this you will need to set up port forwarding on your router to your web server on your machine (you will have to look at your Siemens router documentation on how to do this). You will only be able to do use a custom URL if your router suports dynamic DNS, which most modern routers do. This required because probably the way you access the Internet your IP address can change each time you log in. If this is the case, you can get one free domain for this purpose at DynDNS.

Problems while trying to send emails to Hotmail or Yahoo in AWS EC2

I have a web app in AWS EC2 built on Ruby on Rails and I'm using Devise; when I try to send emails to Gmail it works, but when I try to send emails to Hotmail or Yahoo it fails...
What could it be? Is there a way to make it work without using AWS SES?
Thanks in advance
Most EC2 IP addresses are blacklisted on a lot of email services. You'll want to use something like SES, Sendgrid, or Postmark.
As Michael Fariley explained, the IP addresses are blacklisted. The reason is that its against the terms of use of AWS EC2, so most blacklists will catch a reverse dns that has Amazon EC2 within it.
However, Amazon allows you to change the reverse dns, you just need to ask. You can request it by going to https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request . Make sure that you put the reverse dns in your own dns, so the reversedns address matches the IP of the Elastic IP associated with your server.
i.e. - elastic IP = 1.1.1.1, reverse dns => revdns.mydomain.com = 1.1.1.1
Once your reverse dns has been changed, and you don't abuse it (by spamming, etc) you should be good to go, make sure to check the IP of your instance before and after to see the blacklist has been lifted.

Resources