xtrime-ru/antizapret-vpn-docker
Tentang
Docker container with antizapret-vpn for selfhosting.
Sistem dan infrastrukturYang dapat Anda lakukan
- Modular design. External and high quality opensource modules/containers are used as builing blocks of our system.
- User friendly web panels for administration of VPN's and DNS.
- Multiple VPN transports: WireGuard, AmneziaWG, OpenVPN, and OpenConnect (ocserv).
- AdguardHome as main DNS resolver and blocked domains manager
Pertumbuhan bintang terukur
- dalam 24 jam
- 0
- dalam 7 hari
- +1
- dalam 15 hari
- 0
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
AsliAntiZapret VPN in Docker
Component versions used in this project.
Antizapret created to redirect only blocked domains to VPN tunnel. Its called split tunneling. This repo is based on idea from original AntiZapret LXD image
Table of contents
- Support and discussions group
- Features
- How it works
- Installation
- Documentation
- FAQ (Frequently Asked Questions)
- DNS resolving algorithm
- Routing rules: include, exclude and ASN
- Adding Domains
- SOCKS5 and HTTP(S) Proxy (per-application routing)
- zapret2
- Cloudflare WARP
- Environment Variables
- Container health
- DNS
- OpenConnect (ocserv)
- OpenVPN
- Amnezia Wireguard
- Extra information
- Test speed with iperf3
- Credits
Support and discussions group:
https://t.me/antizapret_support
Features
- Modular design. External and high quality opensource modules/containers are used as builing blocks of our system.
- User friendly web panels for administration of VPN's and DNS.
- Multiple VPN transports: WireGuard, AmneziaWG, OpenVPN, and OpenConnect (ocserv).
- AdguardHome as main DNS resolver and blocked domains manager
- Multi-Server Architecture to bypass services geo restrictions. Different domains use different servers as exit nodes.
- Firewall to protect from port scanning
- Support for kernel modules for OpenVPN and Amnezia Wireguard to decrease CPU usage.
- SOCKS5 and HTTP(S) proxies for per-application routing through local or world exit nodes
- Built-in anti-DPI support with bol-van/zapret2 for HTTP, TLS, and QUIC traffic. Config bundled from vernette/ss-zapret2
How it works?
- AdGuard Home applies its DNS filters and forwards ordinary queries to CoreDNS. Domain-specific upstreams can resolve selected domains directly.
- CoreDNS tries the VPN exit nodes in order:
az-world→az-localin Swarm, or onlyaz-localin single-server Compose. - Each exit node asks AdGuard using its ClientID. Domain exclusions take priority over ordinary includes. Without an exclusion, an include enables VPN routing; otherwise,
dnsmapresolves throughaz-resolverand checks the returned IPv4 addresses against ASN and organization rules. - For a match,
dnsmapallocates virtual IPv4 addresses and creates iptables DNAT mappings to the real addresses. The default pools are14.16.0.0/15for the local exit and14.18.0.0/15for the world exit. - CoreDNS returns virtual addresses from a matching VPN exit. If the exits decline the query or are unavailable, it asks AdGuard for direct DNS resolution. During an exit outage, CoreDNS sets the direct answer's TTL to zero so VPN routing can resume as soon as an exit recovers.
- VPN clients route virtual addresses through the tunnel. Explicit IP/CIDR lists can also add routes for real addresses. See Routing rules: include, exclude and ASN.
Installation
[!IMPORTANT] Commands must be run as root. Otherwise, config files will have inconsistent rights, and some containers will reboot infinitely.
Single Server (Easy)
Recommended to use server located in western countries. Some sites will block users from other countries.
The default Compose configuration runs one az-local exit container. It handles
both the local and world domain lists using the 14.16.0.0/15 range.
- Install Docker Engine:
curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh - Clone repository and start container:
git clone https://github.com/xtrime-ru/antizapret-vpn-docker.git antizapret cd antizapret git checkout v6 - Create docker-compose.override.yml with services you need. Minimal example with only wireguard:
services:
adguard:
environment:
- ADGUARDHOME_PASSWORD=somestrongpassword
wireguard:
environment:
- WIREGUARD_PASSWORD=somestrongpassword
extends:
file: services/wireguard/docker-compose.yml
service: wireguard
Find full example in docker-compose.override.sample.yml
- Start services:
docker compose up -d
docker system prune -f
Docker Swarm, multiple exit nodes (Advanced)
Version 5 and 6 comes with ability to forward traffic to different exit nodes for different domains. For example, YouTube works best if exit node is close to client and other services require foreign IP to work. Docker swarm is used to build unified network between containers.
Yandex Cloud and 1:1 NAT: the encrypted Swarm overlay network may fail to carry traffic between
az-localandaz-worldwhen one server is behind NAT. To work around this, disable encryption throughdocker-compose.override.ymland recreate the network and stack. See the FAQ for details and commands.
Its recommended to use local server as manager/primary node for VPN's, DNS and az-local containers. Foreign server – as secondary/worker node for az-world container.
Most of the domains will be proxied through local server for maximum speed and performance. Some of the sites, which use geoip to block users, will be proxied through foreign server.
- Repeat steps 0 and 1 from single server installation on both servers:
- Install docker
- Checkout project in same location on both servers.
- [Primary] Create docker-compose.override.yml on primary node and define which services you need. See step 2 from single server installation.
- [Primary] Change hostnames of servers to az-local and az-world for ease of use:
hostnamectl set-hostname az-local - [Secondary] Change hostnames of servers to az-local and az-world for ease of use:
hostnamectl set-hostname az-world - [Optionally] hub.docker.com can be unreachable on local hostings. Proxy can be used. See instructions: https://dockerhub.timeweb.cloud
Alternatively images can be built locally on both servers:
docker compose --env-file compose.swarm.env build - [Primary]:
docker swarm init --advertise-addr <PRIMARY_SERVER_PUBLIC_IP_ADDRESS> - [Secondary]: Copy command from results and run it on secondary node:
docker swarm join --token <TOKEN> <MANAGER_IP_ADDRESS>:<PORT> - [Primary]: Inspect swarm
docker node lsID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION 6dzagr08r8d2iidkcumjjz3q7 * az-local Ready Active Leader 29.0.1 vspy2m6w4tf7uv4ywgdnzttvr az-world Ready Active 29.0.1 - [Primary] Add labels for nodes
docker node update --label-add location=local az-local && docker node update --label-add location=world az-world - [Primary]: start swarm. The last Compose file adds
az-worldand splits the address range between both exit nodes:docker compose --env-file compose.swarm.env config | docker run --pull always --rm -i xtrime/antizapret-vpn:6 compose2swarm | docker stack deploy --prune -c - antizapret - [Primary]: Docker Swarm does not support passing host devices to services in the same way as Docker Compose, so VPN containers require DKMS kernel modules:
VPN / Hosting block
Most providers now block vpn connections to foreign IPs. Obfuscation in Amnezia or OpenVpn not always fix the issue. For stable vpn operation you can try to connect to VPS inside your country and then proxy traffic to foreign server.
There are two ways:
- [Recommended] Installation in docker swarm mode
- Proxy all traffic via local proxy. See below.
Example of startup script. Replace <SERVER_IP> with IP address of your server and run it on fresh VPS (ubuntu 24.04 is recommended):
#!/bin/sh
# Fill with your foreign server ip
export VPN_IP=<SERVER_IP>
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.d/99-sysctl.conf
sysctl -w net.ipv4.ip_forward=1
# DNAT rules
iptables -t nat -A PREROUTING -p tcp ! --dport 22 -j DNAT --to-destination "$VPN_IP"
iptables -t nat -A PREROUTING -p udp ! --dport 22 -j DNAT --to-destination "$VPN_IP"
# MASQUERADE rules
iptables -t nat -A POSTROUTING -p tcp -d "$VPN_IP" -j MASQUERADE
iptables -t nat -A POSTROUTING -p udp -d "$VPN_IP" -j MASQUERADE
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
echo iptables-persistent iptables-persistent/autosave_v6 boolean false | sudo debconf-set-selections
apt install -y iptables-persistent
Memory usage
We recommend 1 GB RAM with configured zram, or 2 GB without zram. Zram is compressed swap in RAM: it compresses infrequently used pages without disk access, allocating memory as it fills. Compression uses CPU; severe memory pressure can still cause stalls. Allow headroom for VPN traffic and AdGuard list updates — its memory usage can rise to 500 MiB.
Memory by component
AdGuard stores filters, indexes, and a DNS cache; VPN services store connections and network buffers. Docker, the Linux kernel, and file caches also use RAM. Linux can reclaim file caches when needed.
Approximate production usage (13 containers, a VPS with 1.8 GiB RAM):
| Component | Memory, MiB |
|---|---|
| AdGuard | ≈270 |
| AdGuard during list updates | up to 500 |
az-local |
≈140 |
| CoreDNS | ≈40 |
| WireGuard | ≈45 |
| AmneziaWG | ≈45 |
| OpenVPN | ≈15 |
| OpenVPN UI | ≈20 |
| HTTPS | ≈35 |
| Firewall | ≈2 |
| Proxy | ≈10 |
| ocserv | ≈25 |
| Dashboard | ≈4 |
| IPsec | ≈10 |
| Docker and helper processes | ≈275 |
| Linux kernel (partial estimate) | ≈400 |
The project and system occupied about 1041 MiB (1.02 GiB) excluding caches, counting zram data before compression. Table figures are approximate; rows cannot be added together because some kernel memory is counted twice.
Stress test with limited RAM
Normal operation uses one AdGuard instance. The test ran two instances
with identical filters to simulate elevated memory usage during list updates.
They ran alongside az-local, coredns, firewall, https, wireguard,
wireguard-amnezia, openvpn, and openvpn-ui — ten containers in total.
One CPU, about 1 GB of zram with lzo-rle compression. RAM available to the
system was artificially limited by allocating test data locked in memory
that could not be swapped out. The test lasted about four minutes with light
DNS traffic and no active VPN clients.
| Approximate RAM | Logical memory occupied, MiB | AdGuard response time, ms: median / p95 | Result |
|---|---|---|---|
| 1 GB | 828 | 1.06 / 4.84 | Mean CPU: 17.7% |
| 650 MB | 826 | 1.25 / 7.51 | No DNS errors, OOM kills, or AdGuard restarts; mean CPU: 24% |
| 500 MB | ≈872 | — | Severe stalls; observed 100% CPU |
Response times combine both AdGuard instances, using repeated DNS queries to one domain, mostly cached responses, without VPN. p95 means 95% of responses were faster than this value. No reliable response times are available for 500 MB.
Logical memory occupied is RAM excluding caches and zram itself, plus zram pages before compression, minus test data. The total includes the project, Docker, and the kernel.
At 650 MB RAM, zram stored 616 MiB of data in 144 MiB of RAM, saving about 472 MiB.
Installing and configuring zram
Check swap
swapon --show
zramctl
If /dev/zram0 is already active, it does not need to be created again.
Still check that the kernel metapackage listed for your Ubuntu release is
installed: working zram does not guarantee the module will remain available
after a kernel update. Run the following commands as root on a VPS with a
standard Ubuntu kernel.
Installation on Ubuntu 24.04
apt update
apt install --no-install-recommends \
systemd-zram-generator linux-modules-extra-$(uname -r) \
linux-image-generic linux-firmware-minimal
linux-image-generic pulls in modules for future kernels;
linux-firmware-minimal avoids the large firmware collection.
Installation on Ubuntu 26.04
apt update
apt install --no-install-recommends systemd-zram-generator linux-image-virtual
Zram is included in the regular kernel modules. linux-image-virtual keeps them
updated with the kernel; extra modules and firmware are not needed for zram.
If linux-image-generic is already installed, you can keep it.
Zram size and priority
For both releases, set the capacity equal to RAM and the priority to 100. Capacity is the limit before compression:
modprobe zram
mkdir -p /etc/systemd/zram-generator.conf.d
cat > /etc/systemd/zram-generator.conf.d/90-antizapret.conf <<'EOF'
[zram0]
zram-size = ram
swap-priority = 100
compression-algorithm = zstd
EOF
systemctl daemon-reload
systemctl reset-failed [email protected] dev-zram0.swap
systemctl start dev-zram0.swap
If zram is already active, reboot the VPS to apply the new size and algorithm.
We use zstd at its default compression level of 3 to save RAM.
In the comparative stress test, about 850 MiB of data occupied 142 MiB of RAM
with zstd, versus 202 MiB with lzo-rle, with comparable CPU load.
Zram will start automatically at boot.
Verify zram
Check free -h, swapon --show, and zramctl: zram capacity should equal RAM,
swap priority should be 100, and the algorithm should be zstd.
In free, available shows available RAM;
in zramctl, DATA shows the size before compression and TOTAL shows RAM
allocated to zram including overhead.
After installation
- Make sure Secure DNS is disabled in your browser settings. In chrome: Navigate to Settings > Privacy and security > Security, scroll to the "Advanced" section, and toggle off "Use secure DNS"
- Install DKMS modules for openvpn and/or amnezia wireguard (if you use them):
Access admin panels
HTTPS
By default, all container can be accessed via https. For certificated management separate https container is used.
If no domain is configured, Caddy detects the server's public IPv4 address and requests a short-lived Let's Encrypt certificate for that address. A persistent self-signed certificate is served until ACME validation succeeds, so HTTPS and ocserv can still start when 80/tcp is not reachable from the Internet.
Caddy forwards all connections from its Layer 4 listener on 443/tcp to ocserv and passes the original client address through PROXY protocol v2. The Dashboard uses the separate HTTPS port 444/tcp, while the ocserv DTLS channel is exposed directly on 443/udp.
- dashboard: https://%your-server-ip%:444
- adguard: https://%your-server-ip%:1443
- filebrowser: https://%your-server-ip%:2443
- openvpn: https://%your-server-ip%:3443
- wireguard: https://%your-server-ip%:4443
- wireguard-amnezia: https://%your-server-ip%:5443
Custom sites on ports 80 and 444
Additional Caddy configurations can be stored in config/https/config/sites-enabled. The directory is created automatically when the https container starts, and all files in it are imported into the main Caddyfile.
For example, to expose the my-app service available on port 8080 in the Docker network, create config/https/config/sites-enabled/my-app.caddy:
example.com {
reverse_proxy my-app:8080
}
Caddy will accept requests for example.com on ports 80 and 444, automatically redirect HTTP to HTTPS port 444, and manage the TLS certificate. The domain must point to the server, and the my-app service must be reachable from the https container through the shared Docker network.
Restart the container after adding or changing a configuration:
docker service update --force antizapret_https || docker compose restart https
Local network
When you connected to VPN, you can access containers without exposing ports to internet:
- http://adguard.antizapret:3000
- http://dashboard.antizapret:80
- http://wireguard-amnezia.antizapret:51821
- http://wireguard.antizapret:51821
- http://openvpn-ui.antizapret:8080
- http://filebrowser.antizapret:80
HTTP:
By default, containers don't expose web panels to internet. All web panels are proxied via https container.
If you want to expose http to internet, add port forwarding to docker-compose.override.yml.
Example:
services:
adguard:
#...
ports:
- "3000:3000/tcp"
List of default ports:
- adguard: http://%your-server-ip%:3000
- dashboard: http://%your-server-ip%:80
- wireguard-amnezia: http://%your-server-ip%:51821
- wireguard: http://%your-server-ip%:51821
- openvpn-ui: http://%your-server-ip%:8080
- filebrowser: http://%your-server-ip%:80
Some containers have same ports. So you need to choose unique external port in docker-compose.override.yml.
Update
When upgrading ocserv to 1.6, custom IPv6 configurations must account for the server address changing from the network address plus one to the network address itself. Invalid or unreadable per-user/group configuration files now reject the affected session. The project's default IPv4 configuration needs no changes. Caddy 2.11.9 defaults to a 16 KiB request header limit and one-minute idle read/write timeouts; custom applications that need larger headers or longer stalls can override these in their Caddy configuration.
- Single instance
git pull --rebase docker compose down --remove-orphans docker compose up -d --remove-orphans docker system prune -af - Swarm mode:
git pull --rebase docker pull xtrime/antizapret-vpn:6 docker compose --env-file compose.swarm.env config | docker run --pull always --rm -i xtrime/antizapret-vpn:6 compose2swarm | docker stack deploy --prune -c - antizapret docker system prune -af
Upgrade from v5
- Upgrade containers:
- Docker Compose mode (single server):
docker compose down --remove-orphans git fetch && git checkout v6 && git pull --rebase docker compose down --remove-orphans docker compose up -d --remove-orphans docker system prune -af - Swarm mode:
- master node:
docker stack rm antizapret && sleep 10 git fetch && git checkout v6 && git pull --rebase docker compose --env-file compose.swarm.env config | docker run --pull always --rm -i xtrime/antizapret-vpn:6 compose2swarm | docker stack deploy --prune -c - antizapret docker system prune -af- worker nodes:
git fetch && git checkout v6 && git pull --rebase
- Update clients:
- Wireguard/Amnezia
- Check if your password is longer than 12 symbols. Update if needed in docker-compose.override.yml
- Download new client configs, or add
14.16.0.0/14to AllowedIps manually in old configs.
- OpenVPN
- Click save at openvpn-ui server config page: http://openvpn-ui.antizapret:8080/ov/config/ and then restart openvpn server.
- Install new dkms module on host:
apt remove openvpn-dkms-dco+ https://github.com/xtrime-ru/antizapret-vpn-docker/blob/v6/README.md?tab=readme-ov-file#enable-openvpn-data-channel-offload-dco
- Socks Replace it with proxy container and rename ENV variables. See example: https://github.com/xtrime-ru/antizapret-vpn-docker/blob/v6/docker-compose.override.sample.yml#L75-L105 Make sure you use strong password, because now HTTPS proxy accessible from internet.
- Wireguard/Amnezia
If you added custom AdGuard Home rules that use dnsrewrite=SERVFAIL to skip a
VPN exit node, change those rules to dnsrewrite=REFUSED. AdGuard Home migrates
the two bundled rules automatically.
Reset:
Remove all settings, vpn configs and return initial state of service:
docker stack rm antizapret || docker compose down --remove-orphans
rm -rf config/*
git restore config
Documentation
FAQ (Frequently Asked Questions)
How to get VPN configs?
- OVPN:
- https://%your-server-ip%:3443/certificates
- Create Certificate
- Enter Any Name and leave all other fields as is
- Click "Create". New certificate will appear in the list.
- Click on certificate name in the list to download it.
- Wireguard or Amnezia:
- Go to https://%your-server-ip%:4443 or https://%your-server-ip%:5443
- Click "New"
- Enter any name.
- Create client
- Click download button in the list.
- QR Codes dont work for Amnezia Wireguard, because config is too big for QR code
- OVPN:
Which Amnezia Wireguard client to use? A recommended client for Amnezia Wireguard is AmneziaWG:
Why don't OpenVPN client connect to server? Most providers block openvpn protocol, especially to foreign IPs. The symptoms are: client connects, but after few transferred bytes server stops responding and connection is terminated.
- By default, an openvpn container uses light obfuscation of UDP packets.
It works on most clients (including routers) but still can be blocked by providers.
See OBFUSCATE_TYPE env.
Try to change it from default1(light) to2(strong) or0(off). - Use cascade connection or swarm mode cascade
- By default, an openvpn container uses light obfuscation of UDP packets.
Why can VPN connection be slow and have a lot of dropped packets?
First, use reproducible test to detect issues: Test speed with iperf3
Check if CPU on your hosting is not overloaded during iperf test.
Ensure kernel modules for your VPN are installed and working: OVPN DCO, Amnezia Wireguard Kernel Extension.
Some inexpensive hostings have very slow CPUs, so even with all kernel modules installed, connection speed will not exceed 100 Mbit/s.
Most routers have slow CPUs and provide only 30-60 Mbit/s via openvpn. Try to use Wireguard or Amnezia Wireguard if router supports it or update router to newer model.
By default, new wireguard and openvpn setups use low MTU
1280, to ensure stable connection in all conditions. You can increase up to1480to sligtly increase speed.First, check if your VPN connection has issues with default MTU.
- MacOs:
ping -D -s 1100 youtube.com - Linux:
ping -M do -s 1100 youtube.com - Windows:
ping youtube.com -f -l 1100
For old setups you need manually reduce MTU in settings:
- Wireguard/Amezia:
MTU Must be lower on both server and client.
- Go to http://wireguard.antizapret:51821 or http://wireguard-amnezia.antizapret:51821
- Go to
/admin/interfaceand set MTU there too. - click on client config icon. Lower MTU to
1280and save. - Download and apply new config to your client.
- Test speed with iperf3
- OpenVPN:
- Go to http://openvpn-ui.antizapret:8080/ov/config and add
tun-mtu 1200andmssfix 1232to your server config. - Save Config and restart server.
- Add
tun-mtu 1200andmssfix 1232to your client.conf tun-mtu 1200limits packets inside the tunnel, whilemssfix 1232leaves room for OpenVPN and IPv6/UDP overhead on a 1280-byte path.
- Go to http://openvpn-ui.antizapret:8080/ov/config and add
- MacOs:
If nothing helps, try another hosting and/or cascade
How to debug issues with VPN?
- Check if the VPN connection is established and the DNS server is working:
> nslookup youtube.com Server: 14.16.0.1 Address: 14.16.0.1#53 Non-authoritative answer: Name: youtube.com Address: 14.16.13.209 - Check if browser dont use DoH/Secure DNS.
- Check DIST filters have loaded and have non 0 rule counters: http://adguard.antizapret:3000/#filters
- Check DNS resolution steps: http://adguard.antizapret:3000/#logs?response_status=all&search=youtube.com The number of requests depends on domain rules, ASN fallback, CNAME chains and caching. See: DNS resolving algorithm
- For DNS timeouts, see Swarm connectivity diagnostics.
- Check if the VPN connection is established and the DNS server is working:
DNS timeouts in AdGuard: checking Swarm connectivity
Run docker node and docker service commands on a manager.
1. Identify the DNS server that is timing out
docker service logs --since 10m --tail 200 --timestamps antizapret_adguard
Check upstream= / addr= and the error text. A request to CoreDNS timing out:
[error] dnsproxy: response received upstream_type=main addr=coredns:53 proto=udp status="exchanging with coredns:53 over udp: read udp 10.200.0.33:53380->10.200.0.18:53: i/o timeout"
If only coredns:53 times out while external upstreams such as Google and Cloudflare respond, investigate AdGuard → CoreDNS → az-world/az-local. This does not yet prove packet loss: processing further down the chain may be slow, or a response may be lost on its return path.
Do not confuse the upstream server with the AdGuard client. An external upstream timing out:
[error] dnsproxy: response received upstream_type=custom client_name=coredns addr=https://8.8.8.8:443/dns-query proto=tcp status="… Client.Timeout exceeded while awaiting headers"
Here client_name=coredns identifies the client; Google DNS timed out. Also check external DNS connectivity, outbound HTTPS and upstream errors in this case. Compare errors within the same time window, preferably for the same domain. Requests and responses are also available in the AdGuard query log.
2. Check node availability
docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
ce9ydb2mezb20hvdgtyksdec4 * az-local Ready Active Leader 29.9.0
x0ft0wbjotegkj0o6z51h47r8 az-world Ready Active 29.9.0
Expect Ready and Active, with Leader or Reachable for managers. For Down / Unknown, check host connectivity and the Docker daemon; Drain / Pause affect task placement. Ready confirms Swarm management connectivity, but does not prove that the overlay data path works.
3. Check services and task history
docker service ls
docker service ps --no-trunc antizapret_adguard antizapret_coredns antizapret_az-local antizapret_az-world
NAME MODE REPLICAS IMAGE
antizapret_adguard replicated 1/1 xtrime/antizapret-vpn-adguard:6.9.2
antizapret_az-local replicated 1/1 xtrime/antizapret-vpn:6.9.4
antizapret_az-world replicated 1/1 xtrime/antizapret-vpn:6.9.4
antizapret_coredns replicated 1/1 xtrime/antizapret-vpn-coredns:6.6.4
NAME NODE CURRENT STATE ERROR
antizapret_coredns.1 az-local Running 2 days ago
\_ antizapret_coredns.1 az-local Failed 2 days ago "task: non-zero exit (255)"
Expect 1/1 for these DNS services. Investigate 0/1, Pending, Rejected or repeated recent Failed tasks using ERROR and service logs. docker service ls does not show restart history; docker service ps does. Repeat after 30–60 seconds: current task IDs should remain the same and their running time should increase. An old failure after an update or reboot does not by itself indicate a current problem.
4. Correlate logs with test queries
docker service logs --since 10m --tail 200 --timestamps antizapret_coredns
docker service logs --since 10m --tail 200 --timestamps antizapret_az-local
docker service logs --since 10m --tail 200 --timestamps antizapret_az-world
antizapret_coredns.1.…@az-local | [INFO] 10.200.0.33:51045 - 47063 "A IN example.com. udp 52 false 1232" NOERROR qr,rd,ra,ad 94 0.071461249s
antizapret_az-local.1.…@az-local | Request: [10.200.0.33:38244] (udp) / 'example.com.' (A)
antizapret_az-local.1.…@az-local | Reply: [10.200.0.33:38244] (udp) / 'example.com.' (A) / REFUSED
antizapret_az-world.1.…@az-world | Request: [10.200.0.33:43260] (udp) / 'example.com.' (A)
antizapret_az-world.1.…@az-world | Reply: [10.200.0.33:43260] (udp) / 'example.com.' (A) / RRs: A,A
Look for DNS Request: / Reply: lines and CoreDNS query logs, rather than just HTTP /config-md5/ requests. DNS logging is enabled by default in this project. An exit node may intentionally return REFUSED when a domain does not match its rules, causing CoreDNS to try the next upstream. When az-world answers successfully, the same query need not appear at az-local.
To test each DNS server separately, run these commands on the host running the AdGuard container (usually az-local):
ADGUARD_ID=$(docker ps -q --filter label=com.docker.swarm.service.name=antizapret_adguard --filter status=running | head -n 1)
docker exec "$ADGUARD_ID" busybox nslookup -type=a -retry=1 -timeout=5 example.com coredns.antizapret
docker exec "$ADGUARD_ID" busybox nslookup -type=a -retry=1 -timeout=5 example.com az-world.antizapret
docker exec "$ADGUARD_ID" busybox nslookup -type=a -retry=1 -timeout=5 example.com az-local.antizapret
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47063
example.com. 300 IN A 14.18.138.112
example.com. 300 IN A 14.18.138.111
If ADGUARD_ID is empty, find the correct host using docker service ps antizapret_adguard; docker ps only lists local containers. NOERROR and SERVFAIL both mean a DNS response arrived. communications error … timed out / no servers could be reached mean no response arrived within the configured timeout.
These probes bypass AdGuard's cache. To test the full chain, run nslookup youtube.com 14.16.0.1 on a VPN client; a cached answer or domain-specific upstream may bypass CoreDNS. Direct exit-node probes test the path from AdGuard; check the path from CoreDNS using logs for the same query. CoreDNS may log a query only after processing completes, so wait for a response or timeout.
If docker service logs reports incomplete log stream, missing lines do not prove that queries are missing. Find the current task with docker service ps and read local logs on its host, for example for az-world:
docker ps --filter label=com.docker.swarm.service.name=antizapret_az-world
AZ_WORLD_ID=$(docker ps -q --filter label=com.docker.swarm.service.name=antizapret_az-world --filter status=running | head -n 1)
docker logs --since 10m --tail 200 --timestamps "$AZ_WORLD_ID"
5. Check the firewall and network between servers
If the Docker Swarm overlay network is down, the DNS probes from step 4 to unreachable containers will time out: communications error … timed out / no servers could be reached. Nodes may still be Ready and services may have all replicas running.
Also check whether az-world is reachable from the AdGuard container on az-local:
docker exec "$ADGUARD_ID" ping -c 4 -W 2 az-world.antizapret
If the overlay network is down, ping will receive no replies either (100% packet loss). If DNS queries time out and ping fails, check the firewall and network between servers. A failed ping alone may also be caused by ICMP filtering.
- Check the firewall on both servers: UFW, iptables rules or whichever firewall is in use. It must allow traffic between Swarm nodes, including forwarded container traffic.
- For cloud servers, also check the provider's network rules (security groups).
- Make sure the following Docker Swarm ports and protocols are allowed between nodes:
- TCP
2377— access to managers; - TCP and UDP
7946— communication between nodes; - UDP
4789— overlay network traffic (unless the data path port was changed); - IP protocol
50(ESP) — encrypted overlay traffic. This is a protocol, not port50.
- TCP
- For Yandex Cloud / 1:1 NAT, check the encrypted overlay network issue.
Allow these connections only between Swarm nodes. After correcting the rules, repeat the DNS probes from step 4 and check the logs.
Yandex Cloud: no connectivity between az-local and az-world
If az-local runs in Yandex Cloud (yandex.cloud), missing connectivity to az-world may be caused by Docker Swarm overlay encryption with 1:1 NAT. According to the Yandex Cloud documentation, a VM's public IP is mapped through NAT to its internal address, such as 10.128.0.22. Docker/Moby has an open issue #37115 describing similar symptoms on AWS/GCE: encrypted overlay traffic fails to transit 1:1 NAT. The workaround is to disable overlay network encryption.
An additional symptom is nonzero rule counters for az-local but zero counters for az-world in AdGuard filters. This is a reason to check connectivity between nodes and filter loading; zero counters alone do not prove a NAT issue.
To apply the workaround:
- Add this override to
docker-compose.override.yml:networks: default: driver_opts: encrypted: !reset null!reset nullremoves the inheritedencryptedoption while preserving the other network settings. Do not useencrypted: "false": the presence of this option enables encryption. - On the primary/manager node, remove the stack:
docker stack rm antizapret - Wait for the services and the
antizapret_defaultoverlay network to be removed. Checkdocker stack lsanddocker network ls. If the network remains after the services are removed, delete it manually:docker network rm antizapret_default - Redeploy the entire stack with the updated configuration:
docker compose --env-file compose.swarm.env config | docker run --pull always --rm -i xtrime/antizapret-vpn:6 compose2swarm | docker stack deploy --prune -c - antizapret - Check connectivity to
az-worldand whether its AdGuard filters update.
Restarting containers or updating the stack alone is insufficient: the existing network must be recreated. VPN service will be unavailable while the stack is removed and redeployed. Removing encrypted disables Docker encryption of overlay traffic between servers; the client VPN connection remains encrypted.
DNS resolving algorithm
The diagrams show IPv4 (A) queries. AdGuard uses the ClientIDs az-local, az-world and az-resolver to apply different rules and upstreams to internal requests. AdGuard's default configuration disables AAAA responses.
Docker Swarm
flowchart TB
client["VPN client"] --> adguard["AdGuard Home"]
adguard -->|Blocked| blocked["Blocking response"]
adguard -->|Domain-specific upstream| external["External DNS"]
adguard -->|Ordinary query| core["CoreDNS"]
core --> world["az-world (dnsmap)"]
world -->|Domain or ASN match| world_ip["VPN address: 14.18.0.0/15"]
world -->|Refusal or failure| local_exit["az-local (dnsmap)"]
local_exit -->|Domain or ASN match| local_ip["VPN address: 14.16.0.0/15"]
local_exit -->|Refusal or failure| direct_dns["AdGuard direct DNS (coredns client)"]
direct_dns --> external
adguard -.->|Primary upstream fails| fallback_dns["AdGuard fallback DNS"]
Single node (Docker Compose)
flowchart TB
client["VPN client"] --> adguard["AdGuard Home"]
adguard -->|Blocked| blocked["Blocking response"]
adguard -->|Domain-specific upstream| external["External DNS"]
adguard -->|Ordinary query| core["CoreDNS"]
core --> local_exit["az-local (dnsmap)"]
local_exit -->|Domain or ASN match| local_ip["VPN address: 14.16.0.0/15"]
local_exit -->|Refusal or failure| direct_dns["AdGuard direct DNS (coredns client)"]
direct_dns --> external
adguard -.->|Primary upstream fails| fallback_dns["AdGuard fallback DNS"]
In Swarm, CoreDNS uses az-world, then az-local, then a direct query to AdGuard. It proceeds to the next upstream on a network error, timeout, REFUSED, or SERVFAIL. The final AdGuard request uses the coredns client, whose upstreams are ordinary external resolvers, so it does not loop back into CoreDNS.
On a network error, CoreDNS starts background upstream probes with a 1-second interval between attempts. An upstream skipped by health checks regains its priority after a successful probe. A REFUSED response causes failover for the current query without excluding the upstream.
CoreDNS sets the TTL of fallback answers from AdGuard to zero if a configured exit is missing from discovery, fails to respond, or returns SERVFAIL. Answers from an exit keep their original TTL, as do AdGuard answers when every configured exit replied with REFUSED. Upstream addresses and roles take effect after discovery and Corefile reload.
When upgrading separately, update CoreDNS first, then AdGuard and the exit nodes. On startup, the AdGuard entrypoint updates the two bundled routing rules for az-local and az-world to REFUSED. AdGuard refreshes subscriptions through its regular update process. Update custom routing rules separately if they still use SERVFAIL to skip an exit.
In single-server Compose, CoreDNS uses only az-local before falling back to AdGuard. Both local and world domain lists use the az-local ClientID, and ASN_FILES includes both generated ASN lists. If AdGuard cannot reach its primary upstream, it can use its own fallback resolvers.
Inside an exit node: domains and ASN
flowchart TB
query["Original A query"] --> exit_query["AdGuard using az-local or az-world"]
exit_query -->|NOERROR with A records| mapped["Virtual IPv4 addresses and DNAT"]
exit_query -->|REFUSED| resolver["AdGuard using az-resolver"]
exit_query -->|Other response| original["Return the response to CoreDNS"]
resolver -->|NOERROR with A records| asn_match{"ASN or organization match?"}
resolver -->|Other response| original
asn_match -->|Yes| mapped
asn_match -->|No| refused["Return REFUSED to CoreDNS"]
dnsmapsends the original query to AdGuard using the DoH protocol over internal HTTP at/dns-query/<CLIENT>, with<CLIENT>set toaz-localoraz-world. The default AdGuard DoH port is3000.- For that client, a matching domain include cancels AdGuard's default
REFUSEDrewrite unless an important exclusion also matches. If the response contains IPv4 addresses,dnsmapmaps them immediately; it does not check ASN or queryaz-resolverin this branch. - If the first response is
REFUSED,dnsmapsends the same original query with ClientIDaz-resolver. The default upstreams for this client are Cloudflare, Google and Quad9, rather than CoreDNS. - A matching domain exclusion also returns
REFUSEDforaz-resolver, stopping the ASN check after blocking the ordinary include at the first request. Other resolver errors are also returned without creating mappings. - If direct resolution succeeds,
dnsmapchecks the returned IPv4 addresses in the MaxMind ASN database. If any address matches an ASN number, organization substring or organization regex, all IPv4 addresses in that response are mapped through this exit node. With no matching address, the originalREFUSEDis returned to CoreDNS. - When mapping addresses,
dnsmapremoves CNAME records, replaces A records with virtual addresses under the original query name, and sets their TTL to 300 seconds. It installs DNAT mappings from the virtual addresses to the real addresses.
For an HTTPS query, dnsmap uses a separate A lookup for ASN matching when the exit's ClientID returns REFUSED. It strips IPv4 and IPv6 address hints from returned HTTPS records and drops records that require those hints. An empty answer creates no mappings. A failure to install mappings returns SERVFAIL. The default address pools and rule files are described in Routing rules: include, exclude and ASN.
CNAME resolution and direct exceptions
CoreDNS forwards answers without re-querying each CNAME target. dnsmap checks the resolved IPv4 addresses against MaxMind ASN rules to route CDN traffic.
The bundled lists/exclude.txt loads Steam, PlayStation and Rockstar domain lists from v2fly. AdGuard's Direct Access Rules filter returns important REFUSED rewrites for az-local, az-world and az-resolver, overriding ordinary custom/dist includes and preventing ASN routing. CoreDNS then reaches the direct AdGuard upstream. Independent IP routes still apply. The new list supplies AdGuard rules only; it does not remove entries from include lists.
Reading the query log
When inspecting domain and ASN routing, the AdGuard log can show:
| Client | Response | Meaning |
|---|---|---|
az-world or az-local |
REFUSED |
No include matched, or an important exclusion overrode it; a resolver request follows |
az-resolver |
NOERROR, real IPv4 addresses |
Direct resolution for the subsequent ASN check |
az-resolver |
REFUSED from an exclusion |
Neither domain nor ASN routing is used for this query |
| Original VPN client | NOERROR, 14.18.* or 14.16.* |
An exit node mapped the addresses through the VPN |
A REFUSED entry for an exit ClientID alone does not prove that the exit was skipped: inspect the following az-resolver request and the ASN match messages in the exit container's logs. If all exits return REFUSED, a query from coredns to an ordinary upstream provides the direct answer. Caching and CNAME chains change the number of log entries per client query.
Routing rules: include, exclude and ASN
Distribution (dist) domain, IP and ASN lists are enabled by default. AdGuard Home automatically refreshes the bundled domain lists from GitHub through the list adapter. The antizapret container downloads and updates the IP and ASN lists from GitHub separately. No manual rules are needed for the standard setup. Custom files are optional: use them only to add your own entries or exclude entries from the supplied lists.
Use custom files to route domains and IP networks through the VPN or exclude them. Domain exclusions take priority over ordinary domain includes and ASN routing. IP and ASN exclusion files remove matching rule text from their respective lists; domain exclusions do not remove independent IP/CIDR routes.
Custom rule files
Files are stored in ./config/antizapret/custom/ on the corresponding exit node and mounted into /root/antizapret/config/custom/ inside the container. In Swarm mode, edit domain files on the node whose domain lists you want to change; az-local and az-world use the same filenames on their respective hosts.
| Include file | Exclude file | What it controls |
|---|---|---|
include-hosts-custom.txt |
exclude-hosts-custom.txt |
Domain lists served by this exit node; exclusions also feed important AdGuard rules for az-local, az-world and az-resolver |
include-ips-custom.txt |
exclude-ips-custom.txt |
Local IPv4 addresses and CIDR prefixes |
include-ips-world-custom.txt |
exclude-ips-world-custom.txt |
World IPv4 addresses and CIDR prefixes |
include-asn-custom.txt |
exclude-asn-custom.txt |
Local ASN and organization rules |
include-asn-world-custom.txt |
exclude-asn-world-custom.txt |
World ASN and organization rules |
Including domains
Add one hostname per line to include-hosts-custom.txt, without a URL scheme or path:
example.com
subdomain.example.net
A hostname becomes an AdGuard rule such as @@||example.com^$dnsrewrite,client=az-local (or client=az-world on the world node). It enables VPN address rewriting for the domain and its subdomains. Include lists also accept slash-delimited regular expressions, for example /^service[0-9]+\.example\.net$/.
For custom AdGuard rules and external domain lists, see Adding Domains.
Excluding domains
Add extended regular expressions to exclude-hosts-custom.txt. Use expressions without surrounding / so that the same pattern works for both list filtering and the generated AdGuard rule. For example:
^example\.com$
(^|\.)example\.net$
^steampipe\.akamaized\.net$
The first pattern removes the exact example.com list entry; the second matches example.net and its subdomain entries. Dots are escaped because these files contain regex patterns. Domain list filtering is case-sensitive.
Domain exclusions have two effects:
- The list adapter removes matching input lines from lists with
filter_custom=1(the default). - AdGuard loads exclusions from both exit nodes as important
REFUSEDrewrite rules foraz-local,az-worldandaz-resolver, overriding ordinary includes and stopping ASN fallback.
The adapter filters list entries, not all hostnames covered by the resulting AdGuard rules. Excluding subdomain.example.com does not remove an example.com entry, but the generated important AdGuard exclusion still overrides that parent-domain include for matching queries. The routing order is exclude > include > ASN. Rules entered directly in AdGuard retain its native semantics: an explicit @@…$dnsrewrite,important can override an exclusion. The two default ||*^$dnsrewrite=REFUSED rules stay without important so ordinary includes can cancel them.
Because both exclusion filters target all three internal clients, an exclusion loaded from either node also applies to the other node. Excluding a hostname does not remove independent IP/CIDR routes. CoreDNS no longer re-queries CNAME targets separately.
The bundled lists/exclude.txt is separate from these custom regex files: it uses v2fly syntax and only supplies the Direct Access Rules AdGuard filter. It never removes input lines from include lists. The existing filter_custom option keeps its text-filtering behavior for exclude-hosts-custom.txt.
For example, an ordinary include for example.com can coexist with this generated exclusion:
||direct.example.com^$dnsrewrite=REFUSED,client=az-local|az-world|az-resolver,important
Queries for direct.example.com and its subdomains bypass domain and ASN routing on both exit nodes. The final AdGuard request from coredns is outside the exclusion's client scope and returns the direct answer.
Adding ASNs
ASN rules route domains through a VPN node based on the network that owns their resolved IPv4
addresses. When the regular AdGuard request for az-local or az-world returns REFUSED,
dnsmap resolves the domain directly through the az-resolver client and checks A
records in the MaxMind ASN database. If at least one address matches a rule, all IPv4 addresses
from that DNS response are mapped through the corresponding VPN node. If there are no A records
or none of their networks match, the original filtered response is preserved.
Each non-empty line may contain:
- An exact ASN number:
AS13335or13335 - A case-insensitive substring of the raw MaxMind organization name:
Cloudflare - A case-insensitive regular expression enclosed in
/:/\bg-?core\b/
An exact ASN can be restricted to a DNS query hostname with domain: or regexp::
AS15169 domain:googlevideo.com
AS15169 domain:youtube.com
AS21395 regexp:^rr?[0-9]+---sn-example\.googlevideo\.com$
domain: matches the domain and its subdomains. regexp: matches the queried hostname using Python regular expressions. Both ignore case and the final DNS dot. Each line requires both the ASN and hostname to match; separate lines are alternatives. Use one matcher per line, repeating the ASN to list multiple domains. Commas are part of a regular expression, not list separators. These prefixes follow the domain matcher notation used by v2fly; ASN conditions are a project extension.
Replace an unrestricted ASN entry when adding restrictions: a remaining AS15169 or matching organization rule still routes all domains in that network. Invalid conditions reject the new list; a running resolver retains its previous rules.
Include lists support comments starting with #, on separate lines or after a rule. The same comment syntax is supported in exclude files. Distribution rules
from ASN_URL and ASN_WORLD_URL are combined with the respective custom include files. Exclude
files are applied case-insensitively before the runtime lists are generated.
ASN exclusions use literal, case-insensitive matching with word boundaries (grep -F -i -w). AS15169 removes all lines containing that token, including domain: and regexp: rules, but does not match AS151690 or the bare form 15169. Use the number format written in the include list. A condition can narrow the excluded text; regex syntax in an exclusion is treated literally. Organization exclusions also match whole words: Cloudflare removes Cloudflare Inc. but not NotCloudflare. Remaining organization rules can still match the network. ASN exclusions do not remove independent domain or IP rules.
In single-server Compose mode, ASN_FILES points az-local to both resulting ASN files, so both
lists are routed through the local exit node. In Swarm mode, each exit service receives only its own
ASN file.
For filter debugging, dnsmap logs the IP address, ASN, and organization for both matching and
non-matching networks. ASN data not found means that MaxMind has no record for the address.
Empty addresses and 0.0.0.0 are ignored without a database lookup. A successful match also
prints the exact ASN, substring, or regex rule that triggered routing.
Adding IPs/Subnets
Use these files for custom IP routes:
- Local networks:
./config/antizapret/custom/include-ips-custom.txtand./config/antizapret/custom/exclude-ips-custom.txt. - World networks:
./config/antizapret/custom/include-ips-world-custom.txtand./config/antizapret/custom/exclude-ips-world-custom.txt.
Add IPv4 addresses or CIDR prefixes, one per line, to the corresponding include file:
192.0.2.10
198.51.100.0/24
The custom include file is combined with the distribution list from IPS_URL (local) or IPS_WORLD_URL (world). The corresponding exclude file filters that combined list using extended regular expressions. To remove the two example entries, add:
^192\.0\.2\.10$
^198\.51\.100\.0/24$
This is text filtering, not subnet subtraction: excluding 198.51.100.10 does not remove it from an included 198.51.100.0/24. Unlike domain and ASN rules, IP lists create routes for real addresses without DNS address rewriting. Removing an IP entry does not disable VPN routing triggered by a domain or ASN rule, and exclude-hosts-custom.txt does not remove IP routes.
The VPN client also needs routes for these real addresses. OpenVPN generates push routes from the IP lists; WireGuard/AmneziaWG adds them to its default AllowedIPs when WG_ALLOWED_IPS is unset. After changes, reconnect OpenVPN clients and export/apply updated WireGuard configurations, or use BGP on supported routers.
Direct DNS resolution for domains on VPN-listed CDN networks
The bundled Direct Access Rules filter loads lists/exclude.txt using format=v2fly&exclude=1. Steam, PlayStation and Rockstar use direct resolution even on VPN-listed CDN ASNs. On startup, the updated AdGuard container adds this filter when missing and migrates the standard Excluded Custom Local/World Rules URLs to exclude=1®ex=1, preserving filter IDs and enabled states. The next Docktinel maintenance run refreshes cached filters and clears AdGuard's DNS cache. User rules and Custom include filters are preserved. The old bundled Steam/Rockstar upstream entry is removed.
The separate Direct Access Rules - IP Checkers filter loads the v2fly category-ip-geo-detect list directly. It keeps IP-checking services direct and can be disabled independently of the gaming exclusions.
For your own exceptions, add a regular expression to exclude-hosts-custom.txt. This filters domain list entries and prevents ASN fallback for matching names. Important exclusions also override ordinary include rules covering a broader parent domain. Independent IP routes can still route traffic through VPN.
A domain-specific upstream remains an option for bypassing the complete exit chain: add [/example.com/]https://1.1.1.1/dns-query under Settings → DNS settings → Upstream DNS servers, keeping coredns and the other upstreams. Clear DNS caches after changing rules.
Updating and checking rules
Exit containers check file metadata every 30 seconds and recalculate checksums only after changes. Rebuilding lists may take longer while remote lists are being downloaded. AdGuard detects configuration changes, refreshes its filters and clears its DNS cache. Edit files on the correct exit host in Swarm mode.
After an update, inspect the generated filter in AdGuard, clear the device's DNS cache and repeat the lookup. Addresses in 14.16.0.0/15 indicate the local VPN node; 14.18.0.0/15 indicate the world node. If an exclusion does not work, check the query log for both the original domain and its CNAME targets, the client (az-local, az-world or az-resolver), and the matching rule. ASN matches are also logged by dnsmap.
You can also check blocked ASNs from a Docker host using DPI Detector. Run this command on the network you want to test:
docker run --rm -it --pull=always ghcr.io/runnin4ik/dpi-detector:latest --tests 3
Rebuild IP and ASN lists manually with docker exec $(docker ps -q --filter=name=az | head -n1) doall. Docktinel maintenance jobs refresh domain exclusion matchers and AdGuard filters. Container health
Adding Domains
For custom include/exclude files, see Routing rules: include, exclude and ASN. The following sections explain manual AdGuard rules, external domain lists and routing for a specific client.
Adding Domains via rules
Open adguard panel: http://adguard.antizapret:3000/#custom_rules Rules/syntaxes: https://adguard-dns.io/kb/general/dns-filtering-syntax/#basic-examples
By default, AdGuard returns REFUSED for internal requests from az-local and az-world. A domain rule with @@ and $dnsrewrite allows the exit node to resolve and map that domain through the VPN unless an important exclusion matches. If no include allows the request, dnsmap queries az-resolver; an exclusion stops this request too, otherwise ASN rules are checked. When neither path matches, CoreDNS tries the next upstream. Regular client queries keep the standard AdGuard filtering behavior.
Examples:
@@||subdomain.host.com^$dnsrewrite,client=az-local
@@||*.host.com^$dnsrewrite,client=az-local
# az-world rules apply only in Swarm mode
@@||host.com^$dnsrewrite,client=az-world
@@||de^$dnsrewrite,client=az-world
@@/some_.*_regex/$dnsrewrite,client=az-local
Adding Domains via lists
Also you can add any urls to blocklist. http://adguard.antizapret:3000/#dns_blocklist Need to use adapter, to parse and adapt list in different formats.
- Add domains for local exit node:
http://az-local.antizapret/list/?url=<ANY_URL> - Add domains for the separate world exit node in Swarm mode:
http://az-world.antizapret/list/?url=<ANY_URL> - In single-server Compose mode, use
az-localfor both kinds of domains. Use plain domain lists, slash-delimited regex lists or JSON arrays of domain strings. In plain domain lists, only the first whitespace-separated token is used; trailing attributes and comments are ignored.raw=1and regex rules preserve spaces. Useraw=1for already formatted AdGuard rules; hosts-file IP/name pairs must be converted to domain names before using this adapter.
List adapter options
url- download list from urlfile- read local file. Used for include-host-{custom,dist}.txtfilter_custom=1- filter lists with rules from exclude-hosts-custom.txt.filter_dist=0- filter lists with rules from exclude-hosts-dist.txtformat=list-list,json, orv2fly. JSON is detected from the response Content-Type; withoutformat=, each line is processed as v2fly when it starts withinclude:,domain:,full:,keyword:orregexp:after trimming. Other lines use plain list parsing. This streams the source and its includes without buffering whole lists. Explicitformat=takes priority;raw=1andregex=1disable automatic parsing.exclude=0-exclude=1emits importantREFUSEDrewrites foraz-local|az-world|az-resolver, overriding ordinary includes and disabling ASN fallback. It forcesallow=0,suffix=1,raw=0and disables custom/dist filtering for this exclusion source.client=az-local- name of client to add to rules. Detected automatically.allow=1- disable this option, to block domains from list for this exit node.raw=0- dont modify rulessuffix=1- add "$dnsrewrite,client=xxx" to rulesdnsrewrite=REFUSED- set custom dnsrewrite valueregex=0- useregex=1to wrap each input line as an AdGuard regular expression rule
Incompatible modes return HTTP 400 before loading the source: v2fly with raw=1 or regex=1, raw=1 with regex=1, and exclude=1 with raw=1.
format=v2fly supports bare domains, domain:, exact full:, keyword:, regexp:, # comments and recursive include:filename. Include attributes require all @attr and exclude all @-attr. Filenames resolve relative to the source; absolute HTTP(S) includes are an adapter extension used by lists/exclude.txt. Invalid rules, cycles and excessive nesting fail the request; errors after output begins abort the response. Incoming &list affiliations are not discovered automatically; include those rules explicitly.
Example: http://az-local.antizapret/list/?format=v2fly&exclude=1&url=https://raw.githubusercontent.com/v2fly/domain-list-community/master/data/steam.
Routing a website through VPN for a specific client
To route a specific website through VPN for only one client:
- Find the client's internal IP address in the corresponding VPN server panel or in the AdGuard Home query log.
- Open the AdGuard Home clients page: http://adguard.antizapret:3000/#clients, add the IP address to the client list, and configure the following upstream DNS servers for it:
coredns [/*.antizapret/]127.0.0.11 [/example.com/]udp://coredns.antizapret - Open the AdGuard Home DNS settings: http://adguard.antizapret:3000/#dns and add an upstream for the required domain:
[/example.com/]https://1.1.1.1/dns-query - Add
example.comtoinclude-hosts-custom.txt, or add the following rule on the custom filtering rules page: http://adguard.antizapret:3000/#custom_rules@@||example.com^$dnsrewrite,client=az-local
After configuration, a regular local query in AdGuard Home returns the website's real IP address, while a query from the specified VPN client returns a rewritten internal IP address whose traffic is routed through the VPN.
SOCKS5 and HTTP(S) Proxy (per-application routing)
DNS address rewriting handles connections made through domain names. A connection to a real IP address uses the VPN only if the client's routes and the IP/CIDR lists cover that address. Use a proxy when you want to route an entire application through an exit node without maintaining domain or IP lists.
proxy service is based on 3proxy container
It's a solution for per-application routing.
How it works
- Connect to VPN (OpenVPN, WireGuard or Amnezia WireGuard)
- Configure your application to use SOCKS5 or HTTP/HTTPS proxy via proxy settings or tools like AntizapretSOCKS5 (Windows), ProxyBridge, Proxifier or proxy settings in a web browser.
- All traffic from that application (including direct IP connections) will exit through the selected server node
Two proxy containers are available:
proxy-local.antizapret— traffic exits through the local server- SOCKS5 port:
8118 - HTTP port:
8180 - HTTPS (local) via
httpscontainer:https://%your_ip%:8143
- SOCKS5 port:
proxy-world.antizapret— traffic exits through the world server- SOCKS5 port:
8118 - HTTP port:
8180 - HTTPS (world) via
httpscontainer:https://%your_ip%:8243
- SOCKS5 port:
Authentication: Basic (SOCKS5/HTTP/HTTPS) configured via environment variables. Authentication is required because the HTTPS proxy is accessible from the internet.
How to disable HTTPS access from the internet
Without HTTPS it's safe to use a proxy with an empty username and password.
There are two options:
- Make https container ENV variables for proxy-local.antizapret and proxy-world.antizapret empty.
- Change the hostname in your docker-compose.override.yml, so caddy/https can't reach them by default proxy-local.antizapret.
When to use proxy instead of DNS-based routing
| Scenario | DNS routing | Proxy |
|---|---|---|
| Application connects by domain | ✅ Works | ✅ Works |
| Application connects by IP | ❌ Not routed | ✅ Works |
| Large number of IPs to route | ❌ OpenVPN push routes limit | ✅ No limit |
| Per-application exit node selection | ❌ | ✅ Choose local or world per app |
Configuration
Add proxy services to docker-compose.override.yml:
proxy-local:
hostname: proxy-local.antizapret
extends:
file: services/proxy/compose.yml
service: proxy
environment:
- PROXY_LOGIN=admin
- PROXY_PASSWORD=password
deploy:
mode: replicated
replicas: 1
endpoint_mode: dnsrr
placement:
constraints: [ node.labels.location == local ]
proxy-world:
hostname: proxy-world.antizapret
extends:
file: services/proxy/compose.yml
service: proxy
environment:
- PROXY_LOGIN=admin
- PROXY_PASSWORD=password
deploy:
mode: replicated
replicas: 1
endpoint_mode: dnsrr
placement:
constraints: [ node.labels.location == world ]
Note:
proxy-worldrequires Docker Swarm mode with two nodes. On a single server onlyproxy-localwill work.
Client setup
- Connect to VPN
- Configure the HTTPS proxy exposed by the
httpscontainer in your application or browser:- Host: your server IP address or domain name
- Local proxy port:
8143 - World proxy port:
8243 - Username: value of
PROXY_LOGIN - Password: value of
PROXY_PASSWORD
When connected to the VPN, the proxy containers are also available directly as proxy-local.antizapret and proxy-world.antizapret: SOCKS5 on port 8118 and HTTP on port 8180.
zapret2
zapret2 support is based on bol-van/zapret2, an anti-DPI toolkit that can modify HTTP, TLS, and QUIC traffic, and uses the Docker packaging from vernette/ss-zapret2 as the source of the bundled zapret2 files. In this container it runs on antizapret exit-node traffic and can be tuned with the variables below.
It is disabled by default because it can cause problems on some hostings. To enable anti-DPI processing for HTTP, TLS, and QUIC traffic passing through the antizapret exit node, add it to docker-compose.override.yml:
services:
az-local:
environment:
- ZAPRET_ENABLED=1
If the az-world Swarm node also suffers from DPI, enable it there too:
services:
az-world:
environment:
- ZAPRET_ENABLED=1
On the first start, the default zapret2 config is created at ./config/antizapret/zapret2/zapret.conf.
When zapret2 is enabled, unmodified standard configs from previous versions are automatically updated when the container starts. Configs with user changes are preserved.
Changing configuration
Edit NFQWS2_OPT in this file to tune HTTP, TLS, and QUIC strategies. To disable zapret2 again, set ZAPRET_ENABLED=0.
Apply config changes with the command for your deployment mode:
- Compose mode:
# Docker Compose
docker compose up -d
docker compose restart az-local
- Swarm mode, run on the primary/manager node
docker compose --env-file compose.swarm.env config | docker run --pull always --rm -i xtrime/antizapret-vpn:6 compose2swarm | docker stack deploy --prune -c - antizapret
docker service update --force antizapret_az-local
docker service update --force antizapret_az-world
Strategy selection
To search for working strategies, stop zapret2, run blockcheck2.sh, then start zapret2 again. In Docker Compose mode:
docker exec $(docker ps -q --filter=name=az-local) sh /opt/zapret2/init.d/sysv/zapret2 stop
docker exec $(docker ps -q --filter=name=az-local) sh /opt/zapret2/blockcheck2.sh
docker exec $(docker ps -q --filter=name=az-local) sh /opt/zapret2/init.d/sysv/zapret2 start
For a faster targeted search, pass domains and search options:
docker exec $(docker ps -q --filter=name=az-local) sh -c 'REPEATS=8 DOMAINS="youtube.com discord.com" /opt/zapret2/blockcheck2.sh'
Cloudflare WARP
The official Cloudflare WARP client is included in the antizapret image but is
disabled by default. Enable it for an exit node in
docker-compose.override.yml:
services:
az-local:
environment:
- WARP_ENABLED=1
- WARP_PROTOCOL=WireGuard
- WARP_PORT=500
Use az-world instead for the world exit node. Apply changes with
docker compose up -d.
The defaults are WireGuard on UDP/500. For MASQUE, set WARP_PROTOCOL=MASQUE
and WARP_PORT=443 (HTTP/3 with HTTP/2 fallback). WARP_PORT=0 lets the client
choose its endpoint automatically. No fixed IP is bundled; DNS stays under
Antizapret control. With zapret2, non-default MASQUE UDP ports must also be
added to its firewall and strategy filters.
Registration is stored in ./config/antizapret/warp. When WARP_PROTOCOL
changes, startup automatically replaces the registration; any license
association may need to be restored. Changing only the port keeps it.
Docker Swarm
The same WARP_ENABLED=1 setting works for az-local and az-world in Swarm.
Apply the override using the regular deployment command:
docker compose --env-file compose.swarm.env config | docker run --pull always --rm -i xtrime/antizapret-vpn:6 compose2swarm | docker stack deploy --prune -c - antizapret
Environment Variables
You can define these variables in docker-compose.override.yml file for your needs:
Antizapret:
DNS=adguard- AdGuard host used for DNS-over-HTTPS requests (default:adguard; DoH port:3000).CLIENT=az-local- AdGuard ClientID used by dnsmap. Set toaz-worldon the world node.AZ_SUBNET=14.16.0.0/15- subnet for virtual addresses of blocked hosts. The world node uses14.18.0.0/15.ROUTES- container names and their routed addresses/subnets, used to maintain routes between VPN services, DNS and exit nodes.DOALL_DISABLED=- skip list generation inside the container. Run one generator perresultdirectory. If multiple containers share a directory, setDOALL_DISABLED=1on every reader. Swarm nodes with separate local directories can generate lists independently.IPTABLES_SAVE_DISABLED=- skip iptables rules restore on startup and save on shutdown.WARP_ENABLED=0- set to1to route exit-node traffic through Cloudflare WARP.WARP_PROTOCOL=WireGuard- tunnel protocol:WireGuardorMASQUE(case-sensitive).WARP_PORT=500- endpoint port,1–65535;0lets the client select its endpoint automatically. For MASQUE, normally use443.IPS_URL=- semicolon-separated URLs with IP prefixes for the local node. The merged result is written toresult/ips.txt.IPS_WORLD_URL=- semicolon-separated URLs with IP prefixes for the world node. The merged result is written toresult/ips-world.txt.ASN_URL=- semicolon-separated URLs with ASN numbers or organization names for the local node. The merged result is written toresult/asn.txt.ASN_WORLD_URL=- semicolon-separated URLs with ASN numbers or organization names for the world node. The merged result is written toresult/asn-world.txt.ASN_FILES=- semicolon-separated runtime ASN files read bydnsmap. Compose sets bothasn.txtandasn-world.txtforaz-local; Swarm sets only the corresponding file for each exit service.ZAPRET_ENABLED=0- set to1to enable zapret2 traffic modification for HTTP, HTTPS, and QUIC traffic passing through the container.ZAPRET_CONFIG=/opt/zapret2/config/zapret.conf- path inside the container to the zapret2 configuration file. The default config is created automatically on first start and is persisted at./config/antizapret/zapret2/zapret.conf.
Adguard:
ROUTES- container names and their routed addresses/subnets. The route updater provides reachability to VPN clients and exit nodes; ClientIDs and client IPs are configured separately by the AdGuard entrypoint and Docktinel maintenance job.AZ_WORLD_ENABLED=- enables the separateaz-worldclient, IP tracking, and world configuration checksum. Set automatically to1bycompose.swarm.yml; leave unset in single-server Compose mode.ADGUARDHOME_PORT=3000ADGUARDHOME_USERNAME=adminADGUARDHOME_PASSWORD=ADGUARDHOME_PASSWORD_HASH=- hashed password, taken from the AdGuardHome.yaml file after the first run usingADGUARDHOME_PASSWORD. Dollar sign$in hash must be escaped with another dollar sign:$$
CoreDNS:
- None
Filebrowser:
FILEBROWSER_USERNAME=adminFILEBROWSER_PASSWORD=antizapret-browser— new users require a non-common password of at least 12 characters. Existing users keep their password; change an explicitly configuredpasswordbefore recreating the container.
Https:
PROXY_DOMAIN=- optional domain shared by the HTTPS services and ocserv. If empty, the public IPv4 address is detected at startup.PROXY_EMAIL=- optional email for the Let's Encrypt account.PROXY_IP=- optional public IPv4 override for environments where automatic detection is unavailable.PROXY_CERT_MODE=auto- certificate mode:autokeeps a self-signed fallback while requesting an ACME certificate;selfsigneddisables ACME requests.PROXY_ACME_CA=https://acme-v02.api.letsencrypt.org/directory- ACME directory URL. Use the Let's Encrypt staging directory while testing certificate issuance.PROXY_HTTPS_PORT=444- HTTPS port for the Dashboard and custom Caddy sites. Port443/tcpis reserved for ocserv Layer 4 traffic.
OpenConnect (ocserv)
ROUTES- list of VPN containers and their virtual addresses.OC_DEFAULT_ADDRESS=10.1.164.x- client address range; the value must end in.x.OC_PORT=443- internal TCP and UDP port. Caddy forwards all public443/tcpconnections to it; UDP is published directly.OC_USER=admin- user created on the first start.OC_USERPASS=password- password assigned on the first start.OC_SECRET=kvn- ocserv camouflage secret.
Openvpn
ROUTESOBFUSCATE_TYPE=1- custom obfuscation level of openvpn protocol.- 0 - disable. Regular openvpn client mode, supported by all clients.
- 1 - light obfuscation. Works with microtic and old keenetic routers
- 2 - strong obfuscation. Works with most of the clients: openvpn official gui client, asus routers, new keenetic routers, openwrt routers.
AZ_SUBNET=14.16.0.0/14- subnet for virtual blocked ips.
Openvpn-ui
AZ_SUBNET=14.16.0.0- base address of the virtual/14route pushed to clients; this UI setting is an address without a CIDR suffix.OPENVPN_ADMIN_USERNAME=- replace default username with your usernameOPENVPN_ADMIN_PASSWORD=- replace default password with your passwordOPENVPN_EXTERNAL_IP- external ip of your server, by default detected automaticallyOPENVPN_DNS=14.16.0.1- DNS address for clients. Must be inAZ_SUBNETOPENVPN_LOCAL_IP_RANGE=10.1.165.0- subnet for ovpn clients. Subnet can be viewed in adguard journal or in ovpn-ui panel
Wireguard/Wireguard Amnezia
ROUTESWIREGUARD_PASSWORD=- password for admin panel (used during initial setup only, change password via web UI afterwards)WIREGUARD_USERNAME=admin- username for admin panel (used during initial setup only)AZ_SUBNET=14.16.0.0/14- subnet for virtual blocked ips.WG_DEFAULT_DNS=14.16.0.1- DNS address for clients. Must be inAZ_SUBNETWG_PERSISTENT_KEEPALIVE=25PORT=51821- admin panel portINSECURE=true- allow HTTP access to admin panelDISABLE_IPV6=true- disable IPv6 supportWG_PORT=51820- wireguard server portMTU=1280- default MTU for WireGuard interface and new clientsEXPERIMENTAL_AWG=true- enable AmneziaWG support (wireguard-amnezia only)OVERRIDE_AUTO_AWG=awg- environment variable to force the tunnel type:awgto always use AmneziaWG,wgto always use standard WireGuard; by default it’s unset and automatic detection is used, useful to override auto-selection and lock the mode.BGP_ENABLE=false- start bird BGP server. Server will push routes to clients (some routers). Clients will receive route updates without updating wg/awg config.
SOCKS5 Proxy (deprecated, use proxy below)
SOCKS_USERNAME- legacy alias forPROXY_LOGIN, used by the compatibilitysocksservice.SOCKS_PASSWORD- legacy alias forPROXY_PASSWORD, used by the compatibilitysocksservice.
Proxy (http + socks5)
PROXY_LOGIN- username for HTTP and SOCKS5 authentication.PROXY_PASSWORD- password for HTTP and SOCKS5 authentication. If the login or password is empty, authentication is disabled.PROXY_PORT=8180- HTTP port to listenSOCKS_PORT=8118- SOCKS5 port to listenEXTRA_ACCOUNTS- Additional login:password pairs. Example:login:password;login2:password2EXTRA_CONFIG- Raw 3proxy config lines injected before proxy/socks directives (empty by default)
Container health
Each supervised container runs a Docktinel daemon. The daemon runs the registered startup and runtime checks, schedules maintenance jobs, and supervises helper processes. It launches their commands as child processes and publishes the results in a local state file.
- Docker health. Docker runs
docktinel healthcheckseparately. It reads the daemon's state file and checks that the daemon is alive and still updating it. A freshdegradedstate passes. Three consecutive counted failures setunhealthy. The healthcheck can also stop the application if the daemon exits, its heartbeat expires, or a critical deadline is missed. Docker healthcheck reference - Restart. Docktinel stops the application when a required startup task misses its deadline or a runtime check reaches its failure threshold. Compose restarts the container after exit under
restart: unless-stopped. Swarm can also replace an unhealthy task. The generated Swarm policy retries indefinitely with a 1s delay. An explicitdeploy.restart_policytakes precedence. Swarm task replacement - Background work. Docktinel restarts supervised helpers on exit. Failed periodic jobs report
degradedand retry with backoff. - Route updates. Where configured,
routesstarts with the container and runs continuously, refreshing routes every 10s by default. If it fails to start or exits, Docktinel retries the helper and the container keeps running.
Checks and jobs by service
| Service | Startup checks and deadlines | Runtime checks and restart triggers | Background processes and jobs |
|---|---|---|---|
az-local, az-world |
|
|
|
| AdGuard |
|
|
|
| CoreDNS |
|
|
|
| HTTPS |
|
|
|
| WireGuard and AmneziaWG |
|
|
|
| OpenVPN |
|
|
|
OpenConnect (ocserv) |
|
|
|
| OpenVPN UI |
|
|
— |
HTTP/SOCKS proxy (proxy-local, proxy-world) |
|
|
|
| Dashboard |
|
|
— |
| File Browser |
|
|
— |
| Firewall |
|
|
|
| Cloak |
|
|
— |
Inspect Docktinel tasks with docker exec CONTAINER docktinel status and Docker probe results with docker inspect --format '{{json .State.Health}}' CONTAINER.
DNS
See Container health for DNS probes and restart conditions. VPN containers start and keep running independently of AdGuard availability. DNS recovery uses AdGuard fallback servers, DNS cache reinitialization on dependency changes, and CoreDNS failover. Stopping a WireGuard server does not make clients disconnect or restore ordinary internet routing.
Adguard Upstream DNS
The bundled upstream configuration uses DoH directly over IP: Cloudflare https://1.1.1.1/dns-query, Google https://8.8.8.8/dns-query, Quad9 ECS https://9.9.9.11/dns-query and Yandex Basic https://77.88.8.8/dns-query. Saved provider URLs are not automatically rewritten; regional rules also retain MSK-IX 62.76.76.62.
AdGuard's upstream timeout is 5 seconds. When fallback_dns is empty, the entrypoint adds the fallback DoH servers https://1.1.1.1/dns-query and https://8.8.8.8/dns-query; existing custom fallback servers are retained. Names under *.antizapret also use Docker DNS at 127.0.0.11 in the fallback configuration. Fallback responses contain real IPs and cannot restore an unavailable exit or previously cached synthetic addresses.
Before starting AdGuard, the entrypoint waits up to 60 seconds for DNS registration of az-local, CoreDNS and, when AZ_WORLD_ENABLED=1, az-world. Startup continues when the deadline expires; the Docktinel maintenance job discovers addresses of recovered services. DNS registration does not establish readiness of their DNS and HTTP servers.
When these dependencies disappear, recover, or change IP, the Docktinel maintenance job reinitializes DNS through /control/dns_config before checking for filter updates. This also recreates the HTTP downloader's internal DNS cache, which /control/cache_clear does not clear. The new address snapshot is committed after successful reinitialization; failed attempts are retried. Address changes alone do not trigger filter refresh or change the filter configuration MD5.
AdGuard sends ordinary client queries through CoreDNS, except domains with a separately configured upstream. Bundled Steam/Rockstar direct access is now handled by exclusion filters rather than a dedicated upstream. The default az-local, az-world, coredns and az-resolver clients use Cloudflare, Google and Quad9, with additional domain-specific upstreams where configured. az-resolver is used for direct resolution before ASN checks. Existing saved client settings are retained; when adding a missing az-resolver client to an older configuration, the entrypoint copies the az-local upstreams. The generated configuration is stored in ./config/adguard/conf/AdGuardHome.yaml and can be changed through the AdGuard Home UI.
The third-party xbox-dns.ru resolver can be configured manually as a domain-specific upstream when Gemini incorrectly detects the country from the exit server's IP address and refuses to work because of geographic restrictions. For example:
[/gemini.google.com/generativelanguage.googleapis.com/ai.google.dev/aistudio.google.com/]https://xbox-dns.ru/dns-query
This resolver may return proxy addresses instead of the service's original addresses. These proxy endpoints do not support QUIC or UDP forwarding. Applications that require HTTP/3/QUIC and do not reliably fall back to TCP may therefore fail to connect. For this reason, xbox-dns.ru is not enabled in the default configuration.
CDN + ECS
Some domains can resolve differently, depending on subnet (geoip) of client. In this case using of DNS located on remote server will break some services. ECS allow to provide client IP in DNS requests to upstream server and get correct results. ECS is disabled by default. The AdGuard entrypoint does not enable it automatically in either Docker Compose or Docker Swarm mode.
To enable ECS, open the AdGuard Home DNS settings at http://your-server-ip:3000/#dns, enable EDNS Client Subnet, and replace the preconfigured example address 77.88.8.8 with an address appropriate for your location.
OpenConnect (ocserv)
The ocserv service is compatible with OpenConnect and Cisco AnyConnect clients. It uses the 10.1.164.0/24 subnet and listens on TCP and UDP port 443. Caddy forwards every public 443/tcp connection to ocserv over the internal Docker network with PROXY protocol v2, while Docker publishes the UDP channel directly from the ocserv container. The Dashboard is available separately on 444/tcp; no ALPN-based multiplexing is performed on port 443.
The service is already enabled in the complete docker-compose.override.sample.yml. For an existing installation, add it to docker-compose.override.yml and set a user and a strong password before the first start:
services:
ocserv:
extends:
file: services/ocserv/compose.yml
service: ocserv
environment:
- OC_USER=admin
- OC_USERPASS=strongpassword
Without additional settings, the https service detects the server's public IPv4 address and creates a persistent self-signed fallback certificate. Caddy serves it on port 444 while independently requesting a public Let's Encrypt certificate containing an IP Address SAN, then switches to the managed certificate without stopping the services. Because port 443 is reserved for ocserv, ACME validation uses HTTP-01 on port 80. IP certificates use the mandatory shortlived profile, are valid for 160 hours, and are renewed automatically. Failed ACME attempts are retried while the services remain available with the fallback. For a local installation without a public IP, set PROXY_CERT_MODE=selfsigned to disable ACME attempts. To use a domain for both HTTPS services and ocserv, set PROXY_DOMAIN for the https service.
Allow incoming 443/tcp and 443/udp, then start the service:
docker compose up -d ocserv
User management
OC_USER and OC_USERPASS create the initial user only when ./config/ocserv/ocpasswd does not exist. To add a user or change an existing user's password, run the following command and enter the new password twice:
docker compose exec ocserv \
ocpasswd -g az -c /etc/ocserv/ocpasswd username
To delete, lock, or unlock a user:
docker compose exec ocserv ocpasswd -d -c /etc/ocserv/ocpasswd username
docker compose exec ocserv ocpasswd -l -c /etc/ocserv/ocpasswd username
docker compose exec ocserv ocpasswd -u -c /etc/ocserv/ocpasswd username
To inspect the server and currently connected users:
docker compose exec ocserv occtl show status
docker compose exec ocserv occtl show users
The password database is persisted in ./config/ocserv/ocpasswd.
./config/ocserv/ocserv.tmpl and ./config/ocserv/az.tmpl are persistent, editable templates created only when absent. On every start, environment placeholders are rendered into /run/ocserv/ocserv.conf and /run/ocserv/config-per-group/az; the generated az file is then extended with the current IP routes. Edit the .tmpl files, not the generated runtime files, and restart the container to apply changes. Templates containing literal values continue to work; an environment variable changes a setting only when its placeholder is present in the template.
Client setup
The server address has the following format:
https://SERVER/?SECRET
Use PROXY_DOMAIN as SERVER when configured; otherwise use the server's public IP. SECRET is the configured OC_SECRET and defaults to kvn. The query string is required by ocserv camouflage mode.
For OpenConnect, specify the AnyConnect protocol and the user created above:
sudo openconnect --protocol=anyconnect --user username \
'https://SERVER/?kvn'
In an OpenConnect GUI, select the Cisco AnyConnect protocol and enter the same complete URL. In Cisco Secure Client/AnyConnect, enter SERVER/?kvn in the connection field, connect, and provide the username and password. Port 443 is dedicated to ocserv regardless of ALPN; open the Dashboard at https://SERVER:444.
With a public ACME certificate, no additional certificate setup is needed. When the self-signed fallback is active, inspect the active certificate before accepting the client warning:
openssl x509 -in ./config/https/data/ocserv/certificate.crt \
-noout -subject -issuer -fingerprint -sha256
OpenConnect can pin the fingerprint offered in its warning with the --servercert option. The pin changes when Caddy switches from the fallback to a managed certificate.
The https service stores the fallback, active certificate, and selected identity in ./config/https/data/ocserv; the original public certificate remains in Caddy's managed storage. Caddy copies a valid managed certificate to the active path and uses the self-signed fallback until one is available. If the managed certificate expires or disappears before renewal succeeds, Caddy switches back to the fallback and automatically activates the managed certificate when it becomes available again. ocserv reads the same active certificate, and its Docktinel check restarts the container after renewal, certificate replacement, or an identity change. The fallback is retained between container restarts and regenerated only when the identity changes or it approaches expiration. If the server IP changes, restart the https service so it detects the new address.
Direct IP connections are supported by OpenConnect and Cisco Secure Client. A public IP certificate avoids the manual trust or certificate pinning required by a self-signed certificate.
OpenVPN
Create client certificates:
https://github.com/d3vilh/openvpn-ui?tab=readme-ov-file#generating-ovpn-client-profiles
- go to
http://%your_ip%:8080/certificates - click "create certificate"
- enter unique name. Leave all other fields empty
- click create
- click on certificate name in list to download ovpn file.
Enable OpenVPN Data Channel Offload (DCO)
OpenVPN Data Channel Offload (DCO) provides performance improvements by moving the data channel handling to the kernel space, where it can be handled more efficiently and with multi-threading. tl;dr it increases speed and reduces CPU usage on a server.
Kernel extensions can be installed only on a host machine, not in a container.
Ubuntu 26.04/24.04/22.04/20.04
Ubuntu 26.04 already includes the OpenVPN DCO kernel module in the stock kernel. Installing ovpn-dkms from the OpenVPN repository for 26.04 is optional and is needed only to get a newer module version.
sudo rm -f /etc/apt/sources.list.d/openvpn.list
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo tee /etc/apt/keyrings/openvpn-repo-public.asc > /dev/null
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/openvpn-repo-public.asc] https://build.openvpn.net/debian/openvpn/release/2.7 $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openvpn-aptrepo.list > /dev/null
sudo apt update
sudo apt install -y ovpn-dkms
Legacy clients support
If your clients do not have GCM ciphers support you can use legacy CBC ciphers. DCO is incompatible with legacy ciphers and will be disabled. This is also increase CPU load.
Amnezia Wireguard
Enable Amnezia Wireguard Kernel Extension
https://github.com/amnezia-vpn/amneziawg-linux-kernel-module?tab=readme-ov-file#ubuntu
The WireGuard image is based on stable wg-easy 15.5.0 with AmneziaWG 3.1 tools. Install only the matching DKMS kernel module on the host; awg and awg-quick are already included in the container image.
Ubuntu 26.04/24.04
sudo add-apt-repository ppa:amnezia/ppa
sudo apt update
sudo apt install -y linux-headers-$(uname -r) amneziawg-dkms
Ubuntu 22.04/20.04
- Edit
/etc/apt/sources.listand uncommentdeb-src http://archive.ubuntu.com/ubuntu ... main restricted. - Run:
sudo apt update
sudo apt install -y software-properties-common python3-launchpadlib gnupg2 linux-headers-$(uname -r)
sudo apt-get source linux-image-$(uname -r)
sudo add-apt-repository ppa:amnezia/ppa
sudo apt update
sudo apt install -y amneziawg-dkms
Reboot the host after installing or updating the kernel module; restarting only the container does not replace a loaded module. Then verify that dkms status reports AmneziaWG as installed for the running kernel and that lsmod | grep amneziawg finds the loaded module.
AmneziaWG Parameters
Parameter descriptions can be found in the AmneziaWG documentation and on the kernel module page.
Use AmneziaWG Config Generator to generate unique AmneziaWG parameters.
Parameters Jc, Jmin, Jmax, and I1-I5 can be configured with environment variables. JC, JMIN, and JMAX have defaults; use the AmneziaWG documentation for valid I1-I5 values.
- If an
I1-I5parameter is not set, it will not be included in the configuration. - If all AmneziaWG-specific parameters are absent, AmneziaWG is fully compatible with standard WireGuard.
Supported environment variables:
JC=3JMIN=20JMAX=100I1=...I2=...I3=...I4=...I5=...
Parameter Compatibility Table
| Parameter | Can differ between server and client | Configurable on server | Configurable on client |
|---|---|---|---|
| Jc | ✅ Yes | ✅ Yes | ✅ Yes |
| Jmin | ✅ Yes | ✅ Yes | ✅ Yes |
| Jmax | ✅ Yes | ✅ Yes | ✅ Yes |
| S1–S4 | ❌ No, must match | ✅ Yes | ❌ No (copied from server) |
| H1–H4 | ❌ No, must match | ✅ Yes | ❌ No (copied from server) |
| I1–I5 | ✅ Yes | ✅ Yes | ✅ Yes |
Notes
- Parameters Jc, Jmin, Jmax, I1–I5 can be configured independently on server and client if needed.
- Parameters S1–S4 and H1–H4 must match between server and client; client copies them automatically from the server.
- Use I1–I5 only if you need advanced customization. Otherwise, default automatic values are sufficient.
Amnezia Wireguard Block Size
Amnezia adds random packets to change signature of wireguard protocol and bypass DPI.
By default we use JMIN=20; JMAX=100 for junk packet size in bytes.
Large junk packets can help to bypass DPI, but some firewalls can block them as DDOS attack. Use env variables to change their size if you have issues with amnezia connection:
JC=3
JMIN=20
JMAX=100
or
JC=2
JMIN=10
JMAX=20
Example part of docker-compose.override.yml with JC, JMIN and JMAX:
wireguard-amnezia:
environment:
- WIREGUARD_PASSWORD=xxxxx
- JC=2
- JMIN=10
- JMAX=20
extends:
file: services/wireguard/docker-compose.yml
service: wireguard-amnezia
Settings/env variables are saved in ./config/wireguard_amnezia/ folder. To update them remove folder and run container again. This will also remove all existing clients/certificates.
docker compose down && rm -rf ./config/wireguard_amnezia/ && docker compose up -d
Extra information
- OpenWrt setup guide - how to setup OpenWrt router with this solution to keep LAN clients happy.
- Keenetic setup guide - instructions for configuring the server and connecting Keenetic routers to it (на русском языке)
Test speed with iperf3
iperf3 server is included in antizapret-vpn container.
- Connect to VPN
- Use iperf3 client on your phone or computer to check upload/download speed.
Example 10 threads for 10 seconds and report result every second:
# local node iperf3 -c az-local.antizapret -i1 -t10 -P10 iperf3 -c az-local.antizapret -i1 -t10 -P10 -R # world node iperf3 -c az-world.antizapret -i1 -t10 -P10 iperf3 -c az-world.antizapret -i1 -t10 -P10 -R
Credits
- ProstoVPN — the original project
- AntiZapret VPN Container — source code of the LXD-based container
- AntiZapret PAC Generator — proxy auto-configuration generator to bypass censorship of Russian Federation
- WireGuard — VPN protocol and tools
- wg-easy — WireGuard container and web UI
- AmneziaWG — kernel module
- AmneziaWG tools — command-line tools
- OpenVPN — VPN server
- d3vilh/openvpn-server — OpenVPN base image
- d3vilh/openvpn-ui — OpenVPN management interface
- ocserv — OpenConnect server
- AdGuard Home — DNS resolver and filtering
- CoreDNS — DNS forwarding and failover
- Cloudflare WARP — optional outbound tunnel
- zapret2 — DPI workarounds
- ss-zapret2 — source of the bundled zapret2 files
- Cloak — optional proxy transport
- Docktinel — container health checks and process supervision
- File Browser — web file manager and editor
- lighttpd — dashboard web server
- jitesoft/lighttpd — dashboard base image
- Caddy — HTTPS reverse proxy
- caddy-l4 — TCP forwarding to ocserv
- 3proxy — HTTP and SOCKS5 proxy
- 3proxy-docker — source image for 3proxy
- v2fly/domain-list-community — domain lists used by the routing rules
- MaxMind GeoLite2 ASN — ASN data distributed in the image via P3TERX/GeoLite.mmdb
- P3TERX/GeoLite.mmdb — distribution of the GeoLite2 ASN database
- iperf3 — network throughput testing
- No Thought Is a Crime — the founder’s announcement of the internet censorship research forum
Jelajahi proyek terkait
Memuat…