Skip to content

Instantly share code, notes, and snippets.

@badri
Created April 29, 2022 06:55
Show Gist options
  • Save badri/f87441aa049f03c45de728010f686280 to your computer and use it in GitHub Desktop.
Save badri/f87441aa049f03c45de728010f686280 to your computer and use it in GitHub Desktop.
local base64 = require "ngx.base64"
local httpc = require("resty.http").new()
local base64_encode = base64.encode_base64url
local proxy_opts = {}
local auth_header = "Basic " .. base64_encode("holosix:xN186VaYjrCGepJI")
proxy_opts.http_proxy_authorization = auth_header
proxy_opts.http_proxy = "http://squid.kong-dp.svc.cluster.local:3128"
local res, err = httpc:request_uri("http://httpbin.kong-dp.svc.cluster.local:8000/uuid", {
method = "GET",
ssl_verify = false,
proxy_opts = proxy_opts,
})
if not res then
ngx.log(ngx.ERR, "request failed: ", err)
return
end
local status = res.status
local length = res.headers["Content-Length"]
local body = res.body
ngx.log(ngx.ERR, "body: ", body)
ngx.log(ngx.ERR, "status: ", status)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment