Skip to content

Instantly share code, notes, and snippets.

@lazutov
lazutov / nginx_smtp_blackhole.md
Last active July 27, 2026 11:59
Fast mail backhole for recipient logging with nginx mod smtp

Fast mail backhole for recipient logging with nginx mod smtp

Solution is simple: use nginx as SMTP-proxy with smtpauth hook answering 'No such mailbox' via the same nginx instance (with simple nginx location returning 200 + some headers and access log )

apt install libnginx-mod-mail

# nginx.conf add
mail {
    server_name       mx.your_domain;
@lazutov
lazutov / socks_to_http.md
Created February 8, 2026 21:20
3proxy docker config for simple http proxy over socks for http-only applications (eg. OpenLens)

How to use existing ssh-tunnel as http (not socks) proxy

Usefull for applications, that can use http(connect) proxy, but not socks

If you have a normal ssh dynamic proxy on port 127.0.0.1:7777, this will allow you to accept http-proxy connections on :8080 and forwartd them over upstream soocks proxy (:7777)

docker  run --network host -p8080:8080 -v ./:/etc/3proxy/ --rm -d  3proxy/3proxy
@lazutov
lazutov / docker_debug.md
Created February 8, 2026 21:11
Debug docker container and it`s filesystem with separate image

How to debug docker container, whioch has no shells and debug utilities

Easily, just mount it`s merged filesystems in a new contaner ran into the same pid-namespace

debug.sh

#!/bin/bash
name=$1
varg=""
cnt=0
@lazutov
lazutov / dockerfile_custom_repo.md
Created February 8, 2026 21:04
Use custom mirror in debian apt for docker (Dockerfile)

how to use custom mirror in debian apt in docker (Dockerfile)

simple sed oneliner to replace a repo (adds one thin layer of 1 changed debian.sources)

RUN sed -i -e 's|http://deb.debian.org/debian|http://mirror.yandex.ru/debian|g' /etc/apt/sources.list.d/debian.sources
# then proceed as usual:
RUN apt update && apt install  -y --no-install-recommends your_packages_here && rm -rf /var/lib/apt/lists/*
@lazutov
lazutov / nginx_webdav.md
Last active February 9, 2026 22:14
Nginx file sharing for docker and windows explorer using WebDAV module

Nginx file sharing for docker and windows explorer using WebDAV module

Imageine you have /var/www/videos fileshare that you want to be accessible via windows explorer and you do not want to install NFS or SAMBA
Nginx to rescue! Use built-in webdav module + extra mod-http-dav-ext for windows-specific

apt install nginx libnginx-mod-http-dav-ext
# ensure you have tha basic dav module precompiled. Otherwise refer to you distro repos
nginx -V 2>&1|  tr -s " " "\012" | grep -i dav
@lazutov
lazutov / ssh-tunnel.md
Created February 7, 2026 21:08
add SSH tunnel to systemd

How to add ssh-tunnel as a daemon with systemd

assume you are familiar with ssh-tunnel itself (-L and -R options allow multiple tunnels over one ssh-command) and checked that ssh-command itself works as expected\

lets just add infinite loop and poceed to systemd

#!/bin/bash
while true; do
 ssh -N -p 2222 -L 20099:127.0.0.1:20099 -R 127.0.0.1:9999:127.0.0.1:9999 -R 127.0.0.1:80:127.0.0.1:2080 -i /root/.ssh/tunnelkey.key tunnel@proxy.example.com
@lazutov
lazutov / rtsp_webcam.md
Created February 7, 2026 20:58
Simple RTSP recording with ffmpeg

Simple RTSP recording with ffmpeg

The key point is a usefull set of ffmpeg options explained below:

ffmpeg -hide_banner -y -rtsp_transport tcp -use_wallclock_as_timestamps 1  -threads 1 -i $STREAM -s 640x360 -r 15 \
   -to $DURATION -vcodec copy -acodec aac -timeout 15000000 -map 0  -reset_timestamps 1 \
   -f segment -segment_time 300 -segment_atclocktime 1 -segment_format mp4 -strftime 1 output_%Y-%m-%d_%H-%M-%S.mp4
  • -hide_banner -y -- reduce logging
  • -rtsp_transport tcp -- tcp is much more reliable especially if run over proxy/tunnel
  • -use_wallclock_as_timestamps -- ignore RTSP stream timestams (may be buggy)