Skip to content

Instantly share code, notes, and snippets.

View sabretus's full-sized avatar

Lev Petrushchak sabretus

  • Quiq
  • Ukraine, Lviv
View GitHub Profile
@sabretus
sabretus / gist:167fd1e5a67d9539816ddbb5a9af48c8
Last active August 1, 2022 14:48
Demo test of egress-proxy in Linux
$ docker ps
CONTAINER ID   IMAGE                                      COMMAND                  CREATED             STATUS             PORTS     NAMES
a1b7657f335d   quiq/egress-proxy:1.21.4.1-alpine          "/opt/openresty/bin/…"   About an hour ago   Up About an hour             egress-proxy
$
$ export http_proxy=127.0.0.1:3128 https_proxy=127.0.0.1:3128
$
$ curl -v ifconfig.me
* Uses proxy env variable http_proxy == '127.0.0.1:3128'
* Trying 127.0.0.1:3128…
@sabretus
sabretus / nginx.conf
Last active November 29, 2020 13:34
Advanced Openresty health check for multiple backends using LUA (full example)
upstream other_backend {
server 127.0.0.1:8080;
}
upstream main_backend {
server 127.0.0.1:80;
}
server {
listen 443 ssl http2;
server_name example.com
@sabretus
sabretus / openresty_healthcheck.lua
Last active November 29, 2020 13:36
Advanced Openresty health check for multiple backends using LUA
access_by_lua_block {
local http = require "resty.http"
local h = http.new()
h:set_timeout(2 * 1000)
local url = "http://127.0.0.1:18086/ping"
local res, err = h:request_uri(url, {method = "GET"})
if err or not res or res.status ~= 204 then
ngx.status = ngx.HTTP_SERVICE_UNAVAILABLE
ngx.exit(ngx.HTTP_OK)
end
@sabretus
sabretus / reed_switch.c
Created May 11, 2019 10:31 — forked from rgl/reed_switch.c
connect arduino to a reed switch to read the water flow from a water meter
// this is for an arduino uno.
// this was inspired by http://www.instructables.com/id/Arduino-Reed-Switch/?ALLSTEPS but
// changed to use the arduino internal pull up resistor:
//
// +-----------------+
// | arduino GND -----reed_switch----\
// | | |
// | 12 --------------------/
// +-----------------+
//

Keybase proof

I hereby claim:

  • I am sabretus on github.
  • I am sabretus (https://keybase.io/sabretus) on keybase.
  • I have a public key ASCTJL63kRsVlISfj3pFnGryEfqSF551OIT7zC3FLyJ1sQo

To claim this, I am signing this object: