Skip to content

Instantly share code, notes, and snippets.

View eksiscloud's full-sized avatar

Jakke Lehtonen eksiscloud

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / php.ini
Created June 4, 2020 12:55
Cleaned php7.4.ini (all comments are removed)
[PHP]
;;;;;;;;;;;;;;;;;;;;
; php.ini Options ;
;;;;;;;;;;;;;;;;;;;;
;user_ini.filename = ".user.ini"
;user_ini.filename =
;user_ini.cache_ttl = 300
@eksiscloud
eksiscloud / redis.conf
Last active March 19, 2021 11:59
Simplified /etc/redis/redis.conf
bind 127.0.0.1 ::1
protected-mode yes
port 6379
tcp-backlog 511
# unixsocket /var/run/redis/redis-server.sock
# unixsocketperm 700
timeout 0
tcp-keepalive 300
daemonize yes
@eksiscloud
eksiscloud / wp-config.php
Created June 5, 2020 13:54
Redis and wp-config.php
//define('WP_CACHE', true);
$_SERVER['HTTPS'] = 'on';
//define('DISABLE_WP_CRON', true);
define('WP_REDIS_DATABASE', 1);
$redis_server = array( 'host' => '127.0.0.1', 'port' => 6379, );
define('WP_REDIS_MAXTTL', 900);
define('WP_CACHE_KEY_SALT', 'eksis.dev');
@eksiscloud
eksiscloud / www.conf
Created June 5, 2020 20:10
/etc/php/7.4/fpm/pool.d/www.conf for 1G/1CPU droplet of DigitalOcean
[www]
listen = /run/php/php7.4-fpm.sock
user = www-data
group = www-data
listen.owner = www-data
listen.group = www-data
pm = ondemand
pm.max_children = 2
pm.process_idle_timeout = 10s
pm.max_requests = 100
@eksiscloud
eksiscloud / functions.php
Created June 6, 2020 15:28
Add a link to the Admin Toolbar to easily flush the Redis cache (Redis Object Cache plugin)
# Check: https://onexa.nl/wordpress/toolbar-link-redis-object-cache/
/**
* Add a link to the Admin Toolbar to easily flush the Redis cache (Redis Object Cache plugin)
*
* @author Hiranthi Herlaar, onexa.nl
*
* @var $wp_admin_bar > https://codex.wordpress.org/Class_Reference/WP_Admin_Bar
**/
function redis_add_toolbar_link( $wp_admin_bar )
{