Skip to content

Instantly share code, notes, and snippets.

View eksiscloud's full-sized avatar

Jakke Lehtonen eksiscloud

View GitHub Profile
@eksiscloud
eksiscloud / colortest
Created June 3, 2020 15:24
What do the different colors mean in output of command ls?
#!/bin/bash
# For LS_COLORS, print type and description in the relevant color.
# chmod u+x
IFS=:
for ls_color in $LS_COLORS; do
color="${ls_color#*=}"
type="${ls_color%=*}"
# Add descriptions for named types.
@eksiscloud
eksiscloud / ports.conf
Created June 1, 2020 21:50
Apache2: Ports for Varnish
#Listen 80
Listen 127.0.0.1:81
<IfModule ssl_module>
# Listen 443
</IfModule>
<IfModule mod_gnutls.c>
# Listen 443
</IfModule>
@eksiscloud
eksiscloud / geoipupdate
Created May 23, 2020 17:53
/etc/cron.d/geoipupdate
# Regular cron job for the geoipupdate package, used to update GeoIP databases
#
# According to MaxMind: "The GeoIP2 and GeoIP Legacy Country and City databases
# are updated every Tuesday. The GeoIP2 ISP, GeoIP Legacy ISP and Organization
# databases are updated every one to two weeks. All other databases are updated
# on the first Tuesday of each month."
# m h dom mon dow user command
47 6 * * 3 root test -x /usr/bin/geoipupdate && /usr/bin/geoipupdate
@eksiscloud
eksiscloud / fail2ban
Created May 23, 2020 09:58
/etc/logrotate.d/fail2ban
/var/log/fail2ban.log {
# weekly
daily
# rotate 4
rotate 30
# compress
# delaycompress
missingok
@eksiscloud
eksiscloud / geoip-updater
Last active May 21, 2020 15:17
Udating GeoIP2 database for iptables monthly by cron
#!/usr/bin/env bash
# this script is intended to run with sudo privileges
# It is using GeoLite2xtables to do csv's from MaxMind databases
# Make this executable: sudo chmod +x /etc/cron.monthly/geoip-updater
echo 'Removing old database---------------------------------------------------'
rm -rf /usr/share/xt_geoip/*
mkdir /usr/share/xt_geoip
echo 'Downloading country databases-------------------------------------------'
@eksiscloud
eksiscloud / www.conf
Last active May 2, 2020 07:59
PHP-FPM: pm-pools for 8GB/4CPU VPS where is 20 - 5000 users per day
; DigitalOcean 4 CPU, 8 GB RAM
; PHP7.3-FPM
; If all pools hit in with full power there isn't enough RAM, I reckon.
;
; static
; Wordpress, 2000 - 5000 users per day
[www]
user = www-data
group = www-data
listen = /run/php/php7.3-fpm.sock
@eksiscloud
eksiscloud / hitch
Created April 22, 2020 18:52
Monit: Hitch
# Hitch
check process hitch with pidfile /var/run/hitch.pid
start program = "/usr/bin/systemctl start hitch" with timeout 30 seconds
stop program = "/usr/bin/systemctl stop hitch"
if failed host 127.0.0.1 port 443 type tcpSSL protocol http
and request /index.html with timeout 5 seconds for 2 times within 2 cycles
then restart
if 2 restarts within 2 cycles then timeout
@eksiscloud
eksiscloud / host
Created April 22, 2020 18:31
Monit: Virtual host/domain
### eksis.one
check host eksis.one with address www.eksis.one
# ICMP check
if failed icmp type echo
for 2 times within 2 cycles
then alert
# HTTPS check
if failed port 443 type tcpSSL protocol http
@eksiscloud
eksiscloud / cron
Created April 22, 2020 18:21
Monit: Cron
check process crond with pidfile /var/run/crond.pid
group system
group crond
start program = "/etc/init.d/cron start"
stop program = "/etc/init.d/cron stop"
if 5 restarts with 5 cycles then timeout
depend cron_bin
depend cron_rc
depend cron_spool
@eksiscloud
eksiscloud / postfix
Created April 22, 2020 18:14
Monit: Postfix
# Postfix
check process postfix with pidfile /var/spool/postfix/pid/master.pid
group mail
start program = "/etc/init.d/postfix start"
stop program = "/etc/init.d/postfix stop"
if failed host YOUR-RELAY-HOST port 587
type tcp protocol smtp using tls
with timeout 15 seconds
then alert
if 3 restarts within 5 cycles then timeout