Learn how to securely route Ruby HTTP traffic through a QuotaGuard Shield proxy using the HTTParty library.
Ruby installed.
QUOTAGUARDSHIELD_URL=... bin/qgpass ruby app.rbBe sure to set QUOTAGUARDSHIELD_URL to your Connection URL from the QuotaGuard Dashboard.
docker build -t qg-shield-ruby-httparty-example .
docker run -e QUOTAGUARDSHIELD_URL=... qg-shield-ruby-httparty-example#!/usr/bin/env ruby
require 'httparty'
require 'uri'
proxy = URI.parse("http://localhost:8080")
options = {
http_proxyaddr: proxy.host,
http_proxyport: proxy.port
}
response = HTTParty.get('https://ip.quotaguard.com/', options)
puts response.body, response.code, response.message, response.headers.inspect# Use official Ruby image
FROM ruby:latest
# Install required gems
RUN gem install httparty
# Create a working directory in the container
WORKDIR /app
# Download and extract qgpass
RUN curl https://s3.amazonaws.com/quotaguard/qgpass-latest.tar.gz | tar xz -C /app/
# Copy the Ruby script into the container
COPY app.rb .
# Run our script through qgpass
CMD [ "/app/bin/qgpass", "ruby", "app.rb" ]