adguardHome refactor
This commit is contained in:
+18
@@ -709,6 +709,14 @@ class Bot
|
||||
if (preg_match('~test is successful~', $u)) {
|
||||
$u .= $this->ssh("nginx -s reload 2>&1", 'ng');
|
||||
$this->update($this->input['chat'], $this->input['message_id'], $u);
|
||||
$u .= $this->ssh("/AdGuardHome/AdGuardHome -s stop 2>&1", 'ad');
|
||||
$this->update($this->input['chat'], $this->input['message_id'], $u);
|
||||
$c = yaml_parse_file('/config/adguard/AdGuardHome.yaml');
|
||||
$c['tls']['enabled'] = false;
|
||||
$c['tls']['server_name'] = '';
|
||||
yaml_emit_file('/config/adguard/AdGuardHome.yaml', $c);
|
||||
$u .= $this->ssh("/AdGuardHome/AdGuardHome -s start 2>&1", 'ad');
|
||||
$this->update($this->input['chat'], $this->input['message_id'], $u);
|
||||
unlink('/certs/cert_private');
|
||||
unlink('/certs/cert_public');
|
||||
sleep(3);
|
||||
@@ -763,6 +771,16 @@ class Bot
|
||||
if (preg_match('~test is successful~', $u)) {
|
||||
$out[] = $this->ssh("nginx -s reload 2>&1", 'ng');
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
$out[] = 'Restart Adguard Home';
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
$out[] = $this->ssh("/AdGuardHome/AdGuardHome -s stop 2>&1", 'ad');
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
$c = yaml_parse_file('/config/adguard/AdGuardHome.yaml');
|
||||
$c['tls']['enabled'] = true;
|
||||
$c['tls']['server_name'] = $conf['domain'];
|
||||
yaml_emit_file('/config/adguard/AdGuardHome.yaml', $c);
|
||||
$out[] = $this->ssh("/AdGuardHome/AdGuardHome -s start 2>&1", 'ad');
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
} else {
|
||||
file_put_contents('/config/nginx.conf', $nginx);
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ tls:
|
||||
allow_unencrypted_doh: false
|
||||
certificate_chain: ""
|
||||
private_key: ""
|
||||
certificate_path: ""
|
||||
private_key_path: ""
|
||||
certificate_path: /certs/cert_public
|
||||
private_key_path: /certs/cert_private
|
||||
strict_sni_check: false
|
||||
filters:
|
||||
- enabled: true
|
||||
|
||||
+8
-61
@@ -103,80 +103,27 @@ http {
|
||||
# proxy_set_header Upgrade $http_upgrade;
|
||||
# proxy_set_header Connection "upgrade";
|
||||
# }
|
||||
|
||||
#-ssl
|
||||
# # The DoH server block
|
||||
# location /dns-query {
|
||||
# access_log /logs/nginx_doh_access;
|
||||
# # Proxy HTTP/1.1, clear the connection header to enable Keep-Alive
|
||||
# proxy_http_version 1.1;
|
||||
# proxy_set_header Connection "";
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-Proto https;
|
||||
# proxy_set_header X-Forwarded-For $remote_addr;
|
||||
# proxy_set_header X-Forwarded-Host $remote_addr;
|
||||
|
||||
# # Enable Cache, and set the cache_key to include the request_body
|
||||
# proxy_cache doh_cache;
|
||||
# proxy_cache_key $scheme$proxy_host$uri$is_args$args$request_body;
|
||||
|
||||
# # proxy pass to the dohloop upstream
|
||||
# proxy_pass http://dohloop;
|
||||
# proxy_pass https://ad/dns-query;
|
||||
# }
|
||||
#-ssl
|
||||
# }
|
||||
#-domain
|
||||
|
||||
# This upstream connects to a local Stream service which converts HTTP -> DNS
|
||||
upstream dohloop {
|
||||
zone dohloop 64k;
|
||||
server 127.0.0.1:8053;
|
||||
keepalive_timeout 60s;
|
||||
keepalive_requests 100;
|
||||
keepalive 10;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# DNS Stream Services
|
||||
stream {
|
||||
# DNS logging
|
||||
log_format dns '$remote_addr [$time_local] $protocol "$dns_qname"';
|
||||
access_log /logs/nginx_dns_access dns;
|
||||
|
||||
# Import the NJS module
|
||||
js_import /etc/nginx/njs.d/dns/dns.js;
|
||||
|
||||
# The $dns_qname variable can be populated by preread calls, and can be used for DNS routing
|
||||
js_set $dns_qname dns.get_qname;
|
||||
|
||||
# DNS upstream pool.
|
||||
upstream dns {
|
||||
zone dns 64k;
|
||||
server ad:53;
|
||||
}
|
||||
|
||||
# DNS(TCP) and DNS over TLS (DoT) Server
|
||||
# Terminate DoT and DNS TCP, and proxy onto standard DNS
|
||||
server {
|
||||
listen 53;
|
||||
#-ssl
|
||||
# listen 853 ssl;
|
||||
# ssl_certificate /certs/cert_public;
|
||||
# ssl_certificate_key /certs/cert_private;
|
||||
#-ssl
|
||||
js_preread dns.preread_dns_request;
|
||||
proxy_pass dns;
|
||||
}
|
||||
|
||||
# DNS(UDP) Server
|
||||
# DNS UDP proxy onto DNS UDP
|
||||
server {
|
||||
listen 53 udp;
|
||||
proxy_responses 1;
|
||||
js_preread dns.preread_dns_request;
|
||||
proxy_pass dns;
|
||||
}
|
||||
|
||||
# DNS over HTTPS (gateway) Service
|
||||
# Upstream can be either DNS(TCP) or DoT. If upstream is DNS, proxy_ssl should be off.
|
||||
server {
|
||||
listen 8053;
|
||||
js_filter dns.filter_doh_request;
|
||||
proxy_pass dns;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,12 +141,15 @@ services:
|
||||
args:
|
||||
RELEASE: ${RELEASE}
|
||||
SYSTEM: ${SYSTEM}
|
||||
ports:
|
||||
- 853:853
|
||||
volumes:
|
||||
- ./config/.profile:/root/.bashrc:ro
|
||||
- type: volume
|
||||
target: /opt/adguardhome
|
||||
source: adguard
|
||||
- ./ssh:/ssh
|
||||
- ./certs/:/certs/
|
||||
- ./logs/:/logs/
|
||||
- ./scripts/start_ad.sh:/start_ad.sh
|
||||
hostname: adguard
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
version: "3.7"
|
||||
|
||||
networks:
|
||||
default:
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 10.10.0.0/24
|
||||
volumes:
|
||||
adguard:
|
||||
|
||||
services:
|
||||
ng:
|
||||
build:
|
||||
context: dockerfile
|
||||
dockerfile: doh.dockerfile
|
||||
volumes:
|
||||
- ./config/.profile:/root/.bashrc:ro
|
||||
- ./config/nginx.conf:/etc/nginx/nginx.conf
|
||||
- ./config/nginx_default.conf:/nginx_default.conf
|
||||
- ./scripts/start_ng.sh:/start_ng.sh
|
||||
- ./certs/:/certs/
|
||||
- ./ssh/:/ssh/
|
||||
- ./logs/:/logs/
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
- 53:53/tcp
|
||||
- 53:53/udp
|
||||
hostname: nginx
|
||||
depends_on:
|
||||
- unit
|
||||
- ad
|
||||
- ss
|
||||
environment:
|
||||
TZ: ${TZ}
|
||||
SSPORT: ${SSPORT}
|
||||
stop_grace_period: 1s
|
||||
command: ["/bin/sh", "/start_ng.sh"]
|
||||
networks:
|
||||
default:
|
||||
ipv4_address: 10.10.0.2
|
||||
unit:
|
||||
build:
|
||||
dockerfile: dockerfile/php.dockerfile
|
||||
volumes:
|
||||
- ./config/.profile:/root/.bashrc:ro
|
||||
- ./config/php.ini:/usr/local/etc/php/php.ini
|
||||
- ./config/clients.json:/config/clients.json
|
||||
- ./config/pac.json:/config/pac.json
|
||||
- ./config/unit.json:/config/unit.json
|
||||
- ./config/AdGuardHome.yaml:/config/AdGuardHome.yaml
|
||||
- ./config/nginx.conf:/config/nginx.conf
|
||||
- ./config/nginx_default.conf:/config/nginx_default.conf
|
||||
- ./config/ssserver.json:/config/ssserver.json
|
||||
- ./config/sslocal.json:/config/sslocal.json
|
||||
- ./certs/:/certs/
|
||||
- type: volume
|
||||
target: /config/adguard
|
||||
source: adguard
|
||||
- ./ssh/:/ssh/
|
||||
- ./app:/app
|
||||
- ./logs/:/logs/
|
||||
- ./scripts/start_unit.sh:/start_unit.sh
|
||||
environment:
|
||||
TZ: ${TZ}
|
||||
ADDRESS: ${WGADDRESS}
|
||||
WGPORT: ${WGPORT}
|
||||
SSPORT: ${SSPORT}
|
||||
hostname: unit
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 1s
|
||||
command: ["/bin/sh", "/start_unit.sh"]
|
||||
working_dir: /app
|
||||
networks:
|
||||
default:
|
||||
ipv4_address: 10.10.0.7
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
proxy:
|
||||
build:
|
||||
dockerfile: dockerfile/shadowsocks.dockerfile
|
||||
args:
|
||||
RELEASE: ${RELEASE}
|
||||
SYSTEM: ${SYSTEM}
|
||||
volumes:
|
||||
- ./config/.profile:/root/.bashrc:ro
|
||||
- ./config/sslocal.json:/config.json
|
||||
- ./ssh:/ssh
|
||||
- ./scripts/start_proxy.sh:/start_proxy.sh
|
||||
hostname: proxy
|
||||
depends_on:
|
||||
- unit
|
||||
networks:
|
||||
default:
|
||||
ipv4_address: 10.10.0.3
|
||||
environment:
|
||||
TZ: ${TZ}
|
||||
SSPORT: ${SSPORT}
|
||||
stop_grace_period: 1s
|
||||
command: ["/bin/sh", "/start_proxy.sh"]
|
||||
wg:
|
||||
build:
|
||||
dockerfile: dockerfile/wireguard.dockerfile
|
||||
args:
|
||||
RELEASE: ${RELEASE}
|
||||
SYSTEM: ${SYSTEM}
|
||||
volumes:
|
||||
- ./config/.profile:/root/.bashrc:ro
|
||||
- ./config/wg0.conf:/etc/wireguard/wg0.conf
|
||||
- ./scripts/start_wg.sh:/start_wg.sh
|
||||
- ./scripts/reset_wg.sh:/reset_wg.sh
|
||||
- ./ssh:/ssh
|
||||
hostname: wireguard
|
||||
depends_on:
|
||||
- unit
|
||||
ports:
|
||||
- ${WGPORT}:${WGPORT}/udp
|
||||
environment:
|
||||
TZ: ${TZ}
|
||||
WGPORT: ${WGPORT}
|
||||
ADDRESS: ${WGADDRESS}
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
stop_grace_period: 1s
|
||||
command: ["/bin/sh", "/start_wg.sh"]
|
||||
networks:
|
||||
default:
|
||||
ipv4_address: 10.10.0.4
|
||||
ad:
|
||||
build:
|
||||
dockerfile: dockerfile/adguard.dockerfile
|
||||
args:
|
||||
RELEASE: ${RELEASE}
|
||||
SYSTEM: ${SYSTEM}
|
||||
volumes:
|
||||
- ./config/.profile:/root/.bashrc:ro
|
||||
- type: volume
|
||||
target: /opt/adguardhome
|
||||
source: adguard
|
||||
- ./ssh:/ssh
|
||||
- ./logs/:/logs/
|
||||
- ./scripts/start_ad.sh:/start_ad.sh
|
||||
hostname: adguard
|
||||
depends_on:
|
||||
- unit
|
||||
environment:
|
||||
TZ: ${TZ}
|
||||
stop_grace_period: 1s
|
||||
networks:
|
||||
default:
|
||||
ipv4_address: 10.10.0.5
|
||||
command: ["/bin/sh", "/start_ad.sh"]
|
||||
ss:
|
||||
build:
|
||||
dockerfile: dockerfile/shadowsocks.dockerfile
|
||||
args:
|
||||
RELEASE: ${RELEASE}
|
||||
SYSTEM: ${SYSTEM}
|
||||
volumes:
|
||||
- ./config/.profile:/root/.bashrc:ro
|
||||
- ./config/ssserver.json:/config.json
|
||||
- ./ssh:/ssh
|
||||
- ./scripts/start_ss.sh:/start_ss.sh
|
||||
hostname: shadowsocks
|
||||
depends_on:
|
||||
- unit
|
||||
ports:
|
||||
- ${SSPORT}:${SSPORT}/tcp
|
||||
- ${SSPORT}:${SSPORT}/udp
|
||||
environment:
|
||||
TZ: ${TZ}
|
||||
SSPORT: ${SSPORT}
|
||||
stop_grace_period: 1s
|
||||
command: ["/bin/sh", "/start_ss.sh"]
|
||||
networks:
|
||||
default:
|
||||
ipv4_address: 10.10.0.6
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
from nginx:stable
|
||||
run apt update && \
|
||||
apt install -y git net-tools lsof ssh && \
|
||||
git clone https://github.com/TuxInvader/nginx-dns.git && \
|
||||
cp -r ./nginx-dns/njs.d /etc/nginx/ && \
|
||||
mkdir /root/.ssh
|
||||
|
||||
@@ -14,10 +14,6 @@ wget -O- https://raw.githubusercontent.com/mercurykd/vpnbot/master/scripts/init.
|
||||
|
||||
additional options:
|
||||
|
||||
open 53 port for adguardhome:
|
||||
|
||||
bash scripts/dns_open_53_port.sh
|
||||
|
||||
install as service(autoload on start):
|
||||
|
||||
bash scripts/install_as_service.sh
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
make d
|
||||
rm /etc/systemd/resolved.conf.d/adguardhome.conf
|
||||
mv /etc/resolv.conf.backup /etc/resolv.conf
|
||||
systemctl reload-or-restart systemd-resolved
|
||||
cat docker-compose-init.yml > docker-compose.yml
|
||||
make u
|
||||
@@ -1,10 +0,0 @@
|
||||
mkdir /etc/systemd/resolved.conf.d
|
||||
echo "[Resolve]
|
||||
DNS=127.0.0.1
|
||||
DNSStubListener=no" > /etc/systemd/resolved.conf.d/adguardhome.conf
|
||||
mv /etc/resolv.conf /etc/resolv.conf.backup
|
||||
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
|
||||
systemctl reload-or-restart systemd-resolved
|
||||
cat docker-compose.yml > docker-compose-init.yml
|
||||
cat docker-compose53.yml > docker-compose.yml
|
||||
make d u
|
||||
Reference in New Issue
Block a user