Skip to content

Instantly share code, notes, and snippets.

@jezman
jezman / GeoIP Block NGINX Debian 12.md
Last active September 17, 2025 09:54 — forked from dunderrrrrr/GeoIP Block NGINX Ubuntu 20.04.md
Allow or block GeoIP except LAN in Nginx on Debian 12

GeoIP Block NGINX Debian 12

Block or filter IPs based on location except lan ips in Nginx (tested on 1.22.1) on Debian 12.

Install Nginx modules

To make use of the geographical filtering, we must first install the Nginx GeoIP module as well as the GeoIP database containing the mappings between visitors’ IP addresses and their respective countries. To do so, let’s execute:

$ sudo apt install libnginx-mod-http-geoip geoip-database
@jezman
jezman / wgpeer.sh
Last active April 24, 2025 11:57
Simple create peers for wireguard.
#!/bin/bash
TMPDIR=/tmp/wg_peers
read -p "Username: " USERNAME
USER_DIR=$TMPDIR/$USERNAME
USER_PRIVATEKEY=$USER_DIR/$USERNAME
USER_PUBLICKEY=$USER_DIR/$USERNAME.pub
USER_CONF=$USER_DIR/$USERNAME.conf
@jezman
jezman / check_mounts.sh
Created August 21, 2020 11:21
Сhecking mounted resources by ip.
#!/bin/bash
grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" /etc/fstab | uniq | sort > mount_on_boot
df -h | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | uniq | sort > already_mounted
DIFF=$(diff mount_on_boot already_mounted)
if [ "$DIFF" != "" ]
then
logger "do something"
@jezman
jezman / restart-network.sh
Last active October 24, 2024 07:55
PROXMOX: Apply network settings without reboot.
#/bin/bash
if [[ "$EUID" -ne 0 ]]; then
echo "Permission denied"
exit 1
fi
cp /etc/network/interfaces /etc/network/interfaces.new
systemctl restart networking.service
@jezman
jezman / wgadd.sh
Created February 28, 2020 06:07
Add wireguard peer.
#!/bin/bash
if [[ "$EUID" -ne 0 ]]; then
echo "Permission denied"
exit
fi
WG_CONFIG="/etc/wireguard/wg0.conf"
[ -f $WG_CONFIG ] || echo "Wireguard config not found"; exit 86
@jezman
jezman / switch.expect
Created December 10, 2019 08:42
Dlink switch backup. 1210 and 1510 series.
#!/usr/bin/expect
#==============
# 1510 series =
#==============
set switch "DGS-1510-52"
set ip "switch_ip"
set tftp_host "remote_tftp_server"
set password "pass"
@jezman
jezman / qna.monit.rc
Last active March 7, 2019 07:17
Monit configuration
# Nginx
check process nginx
with pidfile /run/nginx.pid
start program = "/bin/systemctl start nginx.service"
stop program = "/bin/systemctl stop nginx.service"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 127.0.0.1 port 80 protocol http
then restart
-- Создайте базу данных test_guru
CREATE DATABASE test_guru;
-- Таблицу categories с атрибутом title
CREATE TABLE categories(
id SERIAL PRIMARY KEY,
title VARCHAR(50) NOT NULL
);
-- Таблицу tests в которой должны быть атрибуты title, level, внешний ключ к таблице categories
======================================
GET /anything HTTP/1.1
Host: httpbin.org
HTTP/1.1 200 OK
Connection: keep-alive
Server: gunicorn/19.9.0
Date: Mon, 01 Oct 2018 14:10:05 GMT
Content-Type: application/json
Content-Length: 247
@jezman
jezman / github_repo_create.sh
Created October 1, 2018 12:42
Create blank repo on github via bash
#!/usr/bin/env bash
curl -XPOST -H "Authorization: token $GITHUB_TOKEN"\
https://api.github.com/user/repos -d "{\"name\":\"$1\"}"
mkdir ~/github/$1
cd ~/github/$1
echo "# $1" >> README.md
git init
git add README.md
git commit -m "first commit"