Skip to content

Instantly share code, notes, and snippets.

View eksiscloud's full-sized avatar

Jakke Lehtonen eksiscloud

View GitHub Profile
@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 / default.vcl
Last active February 7, 2021 14:33
default.vcl for Varnish (Wordpress, Woocommerce, LearnDash)
## Jakke Lehtonen
## by several sources
## Varnish default.vcl for Wordpress, Woocommerce, LearnDash, PMPro, bbPress etc.
## Just for one domain and one server, but can use for several servers AFAIK
#
# Lets's start caching
#
# Marker to tell the VCL compiler that this VCL has been adapted to the 4.0 format.
vcl 4.0;
@eksiscloud
eksiscloud / services.mon
Last active January 9, 2021 07:32
Monit conf for Varnish, Redis, Hitch and Postfix
# Varnish
check program varnishpanic with path "/bin/varnishadm panic.show"
if status != 1 then alert
check process varnish with pidfile /var/run/varnish.pid
#start program = "/etc/init.d/varnish start" with timeout 30 seconds
#stop program = "/etc/init.d/varnish stop"
start program = "/usr/bin/systemctl start varnish" with timeout 30 seconds
stop program = "/usr/bin/systemctl stop varnish"
if failed host 127.0.0.1 port 80 protocol http
@eksiscloud
eksiscloud / blockbots.conf
Last active November 9, 2020 20:36
Nginx: another bad bot banning list
map $http_user_agent $bad_bot {
default 0;
# libraries etc.
"~*(?:\b)aiohttp(?:\b)" 1;
"~*(?:\b)akka-http/(?:\b)" 1; # - done
"~*(?:\b)Amazon CloudFront(?:\b)" 1; # - done
"~*(?:\b)Facebot Twitterbot(?:\b)" 1;
"~*(?:\b)check_http/(?:\b)" 1;
"~*(?:\b)curl/(?:\b)" 1;
"~*(?:\b)Java/(?:\b)" 1;
@eksiscloud
eksiscloud / sync.sh
Created August 1, 2019 23:29
Syncing two wordpress databases using WP-CLI
#!/bin/sh
DEVDIR="web/app/uploads/"
DEVSITE="https://example.dev"
PRODDIR="web@example.com:/srv/www/example.com/shared/uploads/"
PRODSITE="https://example.com"
STAGDIR="web@staging.example.com:/srv/www/example.com/shared/uploads/"
STAGSITE="https://staging.example.com"
@eksiscloud
eksiscloud / bash_background.vbs
Created July 17, 2020 21:18 — forked from leonelsr/bash_background.vbs
Run bash (Windows Subsystem for Linux) in background, in order to keep background processes running in WSL
' Windows Devs said on the developer feedback asking for cron, deamons and background tasks:
' "This first release of Bash/WSL doesn’t support background tasks, cron jobs, daemons, etc.
' Currently, when you close your last bash shell console window, we tear-down the Linux process
' chain in order to conserve resources."
'
' That's the workaround for now.
' You can run it on boot, for example, and it'll keep a instance of bash running alone in the background
' allowing background processes to run on WSL.
Set WshShell = CreateObject("WScript.Shell")
<?php
# 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
@eksiscloud
eksiscloud / cheshire_cat.vcl
Last active July 2, 2020 17:55
Varnish: custom header a la cheshire cat (ascii art)
sub headers_x {
## Add after vcl 4.1;
## include "/etc/varnish/ext/cheshire_cat.vcl";
##
## Add after sub vcl_deliver {
## call header_smiley;
sub header_smiley {
set resp.http.xa = "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀.'\⠀⠀⠀/`.";
set resp.http.xb = "⠀⠀⠀⠀⠀⠀⠀⠀⠀.'.-.`-'.-.`.";
set resp.http.xc = "⠀⠀⠀⠀..._:⠀⠀⠀.-.⠀.-.⠀⠀⠀:_...";
@eksiscloud
eksiscloud / moomin.vcl
Created July 2, 2020 11:40 — forked from katef/cloud.vcl
HTTP Moomin delivery
sub deliver_moomin {
set resp.http.x-moomin0 = "⠀⠀⠀⠀⠀⠀⠀⢠⢦⡀⠀⡰⣩⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀";
set resp.http.x-moomin1 = "⠀⠀⠀⠀⠀⠀⠀⠘⣄⠙⠍⠁⠙⠦⡀⠀⠀⠀⠀⠀⠀⠀⠀";
set resp.http.x-moomin2 = "⠀⠀⠀⠀⠀⠀⠀⠀⡎⠀⠀⡠⠄⠔⠊⠉⠒⠒⠒⢄⠀⠀⠀";
set resp.http.x-moomin3 = "⠀⠀⠀⠀⠀⠀⠀⢀⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢈⠆⠀⠀";
set resp.http.x-moomin4 = "⠀⠀⢠⢤⠜⡆⠀⢸⠀⠰⣄⠀⠀⠀⠀⠀⠀⠀⣠⠎⠀⠀⠀";
set resp.http.x-moomin5 = "⠀⠀⠱⠤⡁⠈⠑⠇⠀⠀⠀⠉⠒⠤⠤⠄⢖⠊⠀⡐⠧⣄⣀";
set resp.http.x-moomin6 = "⠀⠀⠀⠀⠘⢆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⡉⠀⣀⣨⡷";
set resp.http.x-moomin7 = "⠀⠀⠀⠀⠀⠈⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢱⠜⠁ ";
set resp.http.x-moomin8 = "⠀⠀⠀⠀⠀⠀⢇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣸⠱⡀⠀";
@eksiscloud
eksiscloud / functions.php
Last active June 22, 2020 10:20
Wordpress: Allow/disallow uploading different type/mime files
add_filter( 'upload_mimes', 'my_mime_types', 1, 1 );
function my_mime_types( $mime_types ) {
$mime_types['jpg|jpeg|jpe'] = 'image/jpeg';
$mime_types['gif'] = 'image/gif';
$mime_types['png'] = 'image/png';
$mime_types['bmp'] = 'image/bmp';
$mime_types['tiff|tif'] = 'image/tiff';
$mime_types['ico'] = 'image/x-icon';
$mime_types['asf|asx'] = 'video/x-ms-asf';