Skip to content

Instantly share code, notes, and snippets.

View stargazer's full-sized avatar

Mr Paschalides stargazer

View GitHub Profile
@stargazer
stargazer / script.sh
Created June 1, 2019 11:45
Shell script to run a command as soon as some text is parsed off a log file
sudo journalctl -f -n 1 -b -u volspotconnect2.service | grep --line-buffered "Failed" | while read; do `sudo systemctl restart volspotconnect2`; done
@stargazer
stargazer / frontend-proxy.cfg
Created January 8, 2019 11:45
Understanding rate limiting on HAProxy - 6
frontend proxy
bind *:80
# ACL function declarations
acl is_abuse src_http_req_rate(Abuse) ge 10
acl inc_abuse_cnt src_inc_gpc0(Abuse) gt 0
acl abuse_cnt src_get_gpc0(Abuse) gt 0
# Rules
tcp-request connection track-sc0 src table Abuse
@stargazer
stargazer / backend-abuse.cfg
Created January 8, 2019 11:43
Understanding rate limiting on HAProxy - 5
backend Abuse
stick-table type ip size 100K expire 30m store gpc0,http_req_rate(10s)
@stargazer
stargazer / haproxy-ratelimiter.cfg
Last active January 8, 2019 11:44
Understanding rate limiting on HAProxy - 4
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend proxy
bind *:80
# ACL function declarations
@stargazer
stargazer / Dockerfile
Created January 8, 2019 11:40
Understanding rate limiting on HAProxy - 3
FROM haproxy:1.7
COPY haproxy-ratelimiter.cfg /usr/local/etc/haproxy/haproxy.cfg
@stargazer
stargazer / docker-compose-logs.sh
Created January 8, 2019 11:39
Understanding rate limiting on HAProxy - 2
api01_1 | 192.168.192.3 - - [08/Jan/2019:11:38:09 +0000] "GET / HTTP/1.1" 200 45
api02_1 | 192.168.192.3 - - [08/Jan/2019:11:38:10 +0000] "GET / HTTP/1.1" 304 -
api01_1 | 192.168.192.3 - - [08/Jan/2019:11:38:10 +0000] "GET / HTTP/1.1" 304 -
api02_1 | 192.168.192.3 - - [08/Jan/2019:11:38:11 +0000] "GET / HTTP/1.1" 304 -
api01_1 | 192.168.192.3 - - [08/Jan/2019:11:38:11 +0000] "GET / HTTP/1.1" 304 -
api02_1 | 192.168.192.3 - - [08/Jan/2019:11:38:11 +0000] "GET / HTTP/1.1" 304 -
@stargazer
stargazer / haproxy-basic.cfg
Last active January 8, 2019 11:40
Understanding rate limiting on HAProxy - 1
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend proxy
bind *:80
use_backend api
@stargazer
stargazer / docker1.sh
Last active January 7, 2019 11:12
Dockerize your development environment - 1 - https://medium.com/@already.late/dockerize-your-development-environment-445d417923f0 View docker10.sh
$ git clone git@github.com:stargazer/django-docker.git
$ cd django-docker
root@29abfc7bb280:/src# ./manage.py runserver 0.0.0.0:8080
root@29abfc7bb280:/src# ./manage.py migrate
root@29abfc7bb280:/src# ./manage.py createsuperuser