1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 09:04:12 +02:00

add dns for proxy inside container

This commit is contained in:
Robin Appelman 2026-03-20 21:21:26 +01:00
commit 0d98667650
9 changed files with 37 additions and 12 deletions

View file

@ -66,4 +66,22 @@ then
cp /etc/supervisor/blackfire.conf /etc/supervisor/enabled/
fi
if [ -n "${PROXY_BASE:-}" ]; then
UPSTREAM_DNS=$(cat /etc/resolv.conf | grep nameserver | cut -d' ' -f 2)
(
RC=$(sed '/nameserver/d' /etc/resolv.conf)
echo "$RC" > /etc/resolv.conf
)
echo 'nameserver 127.0.0.22' >> /etc/resolv.conf
echo "s/UPSTREAM_DNS/${UPSTREAM_DNS}"
sed -i "s/UPSTREAM_DNS/${UPSTREAM_DNS}/" /etc/dnsmasq.conf
echo "s/PROXY_BASE/${PROXY_BASE}"
sed -i "s/PROXY_BASE/${PROXY_BASE}/" /etc/dnsmasq.conf
echo "s/HOST_IP/${HOST_IP}"
sed -i "s/HOST_IP/${HOST_IP}/" /etc/dnsmasq.conf
cp /etc/supervisor/dnsmasq.conf /etc/supervisor/enabled/
fi
exec supervisord -c /etc/supervisor/supervisord.conf

View file

@ -1,15 +1,7 @@
{runCommand}:
runCommand "configs" {} ''
mkdir -p $out/etc
mkdir -p $out/etc/sudoers.d
mkdir -p $out/conf
cp ${./configs/cron.conf} $out/etc/oc-cron.conf
cp ${./configs/nginx-app.conf} $out/conf/nginx-app.conf
cp ${./configs/sudoers} $out/etc/sudoers.d/haze
cp -r ${./configs/nc} $out/etc/nc
cp ${./configs/php-fpm.conf} $out/etc/php-fpm.conf
cp ${./configs/nginx.conf} $out/etc/nginx.conf
cp -r ${./configs/supervisor} $out/etc/supervisor
chmod +w $out/etc/supervisor
mkdir -p $out
cp -r ${./configs} $out/etc
chmod -R +w $out/etc
mkdir $out/etc/supervisor/enabled/
''

View file

@ -0,0 +1,6 @@
listen-address=127.0.0.22
no-resolv
address=/PROXY_BASE/HOST_IP
server=UPSTREAM_DNS

View file

@ -79,7 +79,7 @@ http {
}
}
include /conf/nginx-app.conf;
include /etc/nginx-app.conf;
location ~ \.php(?:$|/) {
rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri;

View file

@ -0,0 +1,2 @@
[program:dnsmasq]
command = /bin/dnsmasq --keep-in-foreground -u root

View file

@ -34,6 +34,7 @@
vim,
helix,
python3Packages,
dnsmasq,
}: let
inherit (builtins) toString;
inherit (lib) readFile getExe concatStringsSep splitString take;
@ -149,6 +150,7 @@
vim
helix
python3Packages.supervisor
dnsmasq
];
};

View file

@ -160,6 +160,11 @@ impl PhpVersion {
proxy_config.addr(id, IpAddr::V4(Ipv4Addr::LOCALHOST))
));
env.push(format!("HOST_IP={host}"));
if !proxy_config.address.is_empty() {
env.push(format!("PROXY_BASE={}", proxy_config.address));
}
let mut labels = hashmap! {
"haze-type".to_string() => "cloud".to_string(),
"haze-db".to_string() => db.name().to_string(),